public CollectionConverter(Type CollectionType) { this.CollectionType = CollectionType; this.DataType = ObjectHelper.GetEnumberableType(CollectionType); this.FieldLength = ConverterHelper.GetTypeLength(this.DataType); this.GetObjectBytes = ConverterHelper.GetValueToBytes(this.DataType); this.GetObjectValue = ConverterHelper.GetBytesToValue(this.DataType); if (this.GetObjectBytes == null || this.GetObjectValue == null) { throw new Exception(this.DataType.Name + " is not yet supported."); } }
public static object FromObjectBytes(byte[] bytes) { byte indicatorByte = bytes[0]; var enumtype = (EnumValueType)indicatorByte; var converter = ConverterHelper.GetBytesToValueFromEnum(enumtype); if (converter != null) { int valuelen = bytes.Length - 1; byte[] ValueBytes = new byte[valuelen]; System.Buffer.BlockCopy(bytes, 1, ValueBytes, 0, valuelen); return(converter(ValueBytes)); } return(null); }