Class BinaryProperty
Represents a property of type binary in the Time Cockpit data model.
Inheritance
Implements
Inherited Members
Namespace: TimeCockpit.Data.DataModel
Assembly: TimeCockpit.Data.dll
Syntax
[DataType(typeof(byte[]))]
[Column(typeof(byte[]), SizePropertyName = "MaxStorageSize")]
[DefaultValue(new byte[]{})]
[FriendlyTypeName("Binary")]
public class BinaryProperty : PersistedProperty, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo, INullable
Remarks
Binary properties store binary data either in the database or in the separated blob storage. You can specify where binary data should be stored using the StorageType property. Note that the value of this property must not be changed after the initial creation of the property.
Binary data can be compressed and/or encrypted before storage. You can enable compression and/or encryption using the ContentProcessing property. Note that the value of this property must not be changed after the initial creation of the property.
The class BinaryProperty
can handle data in the form of byte[]
. However, you can derive
from BinaryProperty
and accept data in more complex forms there. BinaryProperty
cares
for saving and loading of the data from storage; you have to provide the necessary serialization and
deserialization logic by overriding Unpack(Byte[], Byte[]) and Pack(Object, Byte[]).
Constructors
BinaryProperty()
Initializes a new instance of the BinaryProperty class
Declaration
public BinaryProperty()
BinaryProperty(IEnumerable<KeyValuePair<Object, Object>>)
Initializes a new instance of the BinaryProperty class
Declaration
public BinaryProperty(IEnumerable<KeyValuePair<object, object>> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Object, System.Object>> | properties | Collection of properties |
BinaryProperty(BinaryProperty)
Initializes a new instance of the BinaryProperty class.
Declaration
public BinaryProperty(BinaryProperty element)
Parameters
Type | Name | Description |
---|---|---|
BinaryProperty | element | The element. |
Properties
ClrDefaultValue
Gets the default valud for the datatype for the property.
Declaration
public override object ClrDefaultValue { get; }
Property Value
Type | Description |
---|---|
System.Object |
Overrides
ContentProcessing
Gets or sets the content processing for the binary property
Declaration
public ContentProcessing ContentProcessing { get; set; }
Property Value
Type | Description |
---|---|
ContentProcessing |
Remarks
This property defines how new rows are written. The property is not relevant when reading rows because in this case the content processing encoded in the blob header is interpreted.
DataType
Gets the datatype for the property.
Declaration
public override Type DataType { get; }
Property Value
Type | Description |
---|---|
System.Type |
Overrides
MaxStorageSize
Gets or sets the maximum storage size of the binary property
Declaration
[SchemaDatabaseMapping(SchemaDatabaseColumn.PropertyLengthPrecision)]
public int MaxStorageSize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
StorageType
Gets or sets the storage type for the property
Declaration
public StorageType StorageType { get; set; }
Property Value
Type | Description |
---|---|
StorageType |
Methods
Convert(Object)
Converts an object to the type of the property.
Declaration
public override object Convert(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object to convert. |
Returns
Type | Description |
---|---|
System.Object | Returns the converted object. |
Overrides
Pack(Object, Byte[])
Converts a content's target form into it's binary representation
Declaration
protected virtual byte[] Pack(object content, byte[] blobEncryptionKey)
Parameters
Type | Name | Description |
---|---|---|
System.Object | content | Content's target form |
System.Byte[] | blobEncryptionKey | optional encryption key which can be used for storing blobs |
Returns
Type | Description |
---|---|
System.Byte[] | Binary representation of |
Remarks
If content
is null or System.DBNull.Value
the method returns null.
Note to implementers: If you provide your own specialized version of CipherBlobContent
you have to call the base class' method to compressed/encrypted the serialized data (array of bytes)
you have created.
Unpack(Byte[], Byte[])
Converts the binary content into it's target form
Declaration
protected virtual object Unpack(byte[] content, byte[] blobEncryptionKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | content | Binary content |
System.Byte[] | blobEncryptionKey | optional encryption key which can be used for storing blobs |
Returns
Type | Description |
---|---|
System.Object | The content's target form |
Remarks
If content
is null the method returns null.
Note to implementers: If you provide your own specialized version of DecipherBlobContent
you have to call the base class' method to get the decompressed/decrypted array of bytes from
which you can deserialize your data.
Validate(ref IList<PropertyValidationMessage>, Boolean)
Validates a ModelElement according to certain rules.
Declaration
protected override void Validate(ref IList<PropertyValidationMessage> messages, bool validateRecursively)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<PropertyValidationMessage> | messages | An list of strings that stores that picks up the validation errors of a model element. |
System.Boolean | validateRecursively | Indicates wheter to validate only the current model element or all its children (recursively) as well. |
Overrides
Remarks
The rules the ModelElement is validated against are dependent on the type of ModelElement that is validated. This method can be overridden to provide custom validation behavior for subclasses of ModelElement
When Validate(ref IList<PropertyValidationMessage>, Boolean) is called on a modelelement, the Validate(ref IList<PropertyValidationMessage>, Boolean) method of all children attatched to the modelelemnt are validated recursivly.
ValidateValue(Object, out String)
Validates that the value is of type byte[] or null, if the property is null-able.
Declaration
public override bool ValidateValue(object value, out string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to validate. |
System.String | errorMessage | The resulting error message, or null if there is none. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the value is valid, false otherwise. |