Class BinaryProperty
- Namespace
- TimeCockpit.Data.DataModel
- Assembly
- TimeCockpit.Data.dll
Represents a property of type binary in the Time Cockpit data model.
[DataType(typeof(byte[]))]
[Column(typeof(byte[]), SizePropertyName = "MaxStorageSize")]
[DefaultValue(new byte[]{})]
[FriendlyTypeName("Binary")]
public class BinaryProperty : PersistedProperty, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo, INullable
- Inheritance
-
ObjectBinaryProperty
- Implements
-
IDynamicMetaObjectProviderINotifyPropertyChangedIDataErrorInfo
- Derived
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
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
public BinaryProperty()
BinaryProperty(IEnumerable<KeyValuePair<Object, Object>>)
Initializes a new instance of the BinaryProperty class
public BinaryProperty(IEnumerable<KeyValuePair<object, object>> properties)
Parameters
propertiesIEnumerable<KeyValuePair<Object, Object>>Collection of properties
BinaryProperty(BinaryProperty)
Initializes a new instance of the BinaryProperty class.
public BinaryProperty(BinaryProperty element)
Parameters
elementBinaryPropertyThe element.
Properties
ClrDefaultValue
Gets the default valud for the datatype for the property.
public override object ClrDefaultValue { get; }
Property Value
- Object
ContentProcessing
Gets or sets the content processing for the binary property
public ContentProcessing ContentProcessing { get; set; }
Property Value
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.
public override Type DataType { get; }
Property Value
- Type
MaxStorageSize
Gets or sets the maximum storage size of the binary property
[SchemaDatabaseMapping(SchemaDatabaseColumn.PropertyLengthPrecision)]
public int MaxStorageSize { get; set; }
Property Value
- Int32
StorageType
Gets or sets the storage type for the property
public StorageType StorageType { get; set; }
Property Value
Methods
Convert(Object)
Converts an object to the type of the property.
public override object Convert(object value)
Parameters
valueObjectObject to convert.
Returns
- Object
Returns the converted object.
Pack(Object, Byte[])
Converts a content's target form into it's binary representation
protected virtual byte[] Pack(object content, byte[] blobEncryptionKey)
Parameters
contentObjectContent's target form
blobEncryptionKeyByte[]optional encryption key which can be used for storing blobs
Returns
- Byte[]
Binary representation of
content
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
protected virtual object Unpack(byte[] content, byte[] blobEncryptionKey)
Parameters
contentByte[]Binary content
blobEncryptionKeyByte[]optional encryption key which can be used for storing blobs
Returns
- 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.
protected override void Validate(ref IList<PropertyValidationMessage> messages, bool validateRecursively)
Parameters
messagesIList<PropertyValidationMessage>An list of strings that stores that picks up the validation errors of a model element.
validateRecursivelyBooleanIndicates wheter to validate only the current model element or all its children (recursively) as well.
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.
public override bool ValidateValue(object value, out string errorMessage)
Parameters
valueObjectThe value to validate.
errorMessageStringThe resulting error message, or null if there is none.
Returns
- Boolean
Returns true if the value is valid, false otherwise.