private static object ConvertPropertyValue(PropertyDefinition propertyDefinition, object value)
        {
            Type type = value.GetType();

            if (propertyDefinition.Type == type)
            {
                return(value);
            }
            if (propertyDefinition.Type == typeof(Guid) && type == typeof(string))
            {
                return(Guid.Parse((string)value));
            }
            if (propertyDefinition.Type == typeof(ExDateTime) && type == typeof(long))
            {
                return(ExDateTime.FromFileTimeUtc((long)value));
            }
            if (propertyDefinition.Type == typeof(StoreObjectId) && type == typeof(byte[]))
            {
                return(StoreObjectId.Parse((byte[])value, 0));
            }
            throw new NotSupportedException(string.Format("The conversation from serialized property type {0} to actual property type {1} for {2} is not supported.", type.FullName, propertyDefinition.Type.FullName, propertyDefinition.Name));
        }
Example #2
0
 public static StoreObjectId GetStoreObjectId(byte[] objectBytes)
 {
     return(StoreObjectId.Parse(objectBytes, 0));
 }