Пример #1
0
 /// <summary>
 /// Serialize the actual object into the given data storage.
 /// </summary>
 /// <param name="instance">
 /// The object instance to serialize. This will never be null.
 /// </param>
 /// <param name="serialized">The serialized state.</param>
 /// <param name="storageType">
 /// The field/property type that is storing this instance.
 /// </param>
 /// <returns>If serialization was successful.</returns>
 public abstract fsResult TrySerialize(object instance, out fsData serialized, Type storageType);
Пример #2
0
 protected fsResult FailExpectedType(fsData data, params fsDataType[] types)
 {
     return(fsResult.Fail(GetType().Name + " expected one of " +
                          string.Join(", ", types.Select(t => t.ToString()).ToArray()) +
                          " but got " + data.Type + " in " + data));
 }
Пример #3
0
 protected fsResult CheckKey(fsData data, string key, out fsData subitem)
 {
     return(CheckKey(data.AsDictionary, key, out subitem));
 }
Пример #4
0
        public override void OnBeforeDeserializeAfterInstanceCreation(Type storageType, object instance, ref fsData data)
        {
            if (instance is fsISerializationCallbacks == false)
            {
                throw new InvalidCastException("Please ensure the converter for " + storageType + " actually returns an instance of it, not an instance of " + instance.GetType());
            }

            ((fsISerializationCallbacks)instance).OnBeforeDeserialize(storageType, ref data);
        }
Пример #5
0
 /// <summary>
 /// Deserialize data into the object instance.
 /// </summary>
 /// <param name="data">Serialization data to deserialize from.</param>
 /// <param name="instance">
 /// The object instance to deserialize into.
 /// </param>
 /// <param name="storageType">
 /// The field/property type that is storing the instance.
 /// </param>
 /// <returns>
 /// True if serialization was successful, false otherwise.
 /// </returns>
 public abstract fsResult TryDeserialize(fsData data, ref object instance, Type storageType);
Пример #6
0
		public override object CreateInstance(fsData data, Type storageType)
		{
			return new Keyframe();
		}
Пример #7
0
        public override object CreateInstance(fsData data, Type storageType)
        {
            var metaType = fsMetaType.Get(Serializer.Config, storageType);

            return(metaType.CreateInstance());
        }
 public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType)
 {
     // null is automatically deserialized
     return(Serializer.TryDeserialize(data, Nullable.GetUnderlyingType(storageType), ref instance));
 }
 public override object CreateInstance(fsData data, Type storageType)
 {
     return(storageType);
 }
 public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType)
 {
     // null is automatically serialized
     return(Serializer.TrySerialize(Nullable.GetUnderlyingType(storageType), instance, out serialized));
 }
Пример #11
0
 /// <summary>
 /// Called before deserialization has begun but *after* the object
 /// instance has been created. This will get invoked even if the user
 /// passed in an existing instance.
 /// </summary>
 /// <remarks>
 /// **IMPORTANT**: The actual instance that gets passed here is *not*
 /// guaranteed to be an a subtype of storageType, since the value for
 /// instance is whatever the active converter returned for
 /// CreateInstance() - ie, some converters will return dummy types in
 /// CreateInstance() if instance creation cannot be separated from
 /// deserialization (ie, KeyValuePair).
 /// </remarks>
 /// <param name="storageType">
 /// The field/property type that is storing the instance.
 /// </param>
 /// <param name="instance">
 /// The created object instance. No deserialization has been applied to
 /// it.
 /// </param>
 /// <param name="data">
 /// The data that will be used for deserialization.
 /// </param>
 public virtual void OnBeforeDeserializeAfterInstanceCreation(Type storageType, object instance, ref fsData data)
 {
 }
Пример #12
0
 /// <summary>
 /// Called before deserialization.
 /// </summary>
 /// <param name="storageType">
 /// The field/property type that is storing the instance.
 /// </param>
 /// <param name="data">
 /// The data that will be used for deserialization.
 /// </param>
 public virtual void OnBeforeDeserialize(Type storageType, ref fsData data)
 {
 }
Пример #13
0
 /// <summary>
 /// Called after serialization.
 /// </summary>
 /// <param name="storageType">
 /// The field/property type that is storing the instance.
 /// </param>
 /// <param name="instance">The type of the instance.</param>
 /// <param name="data">The data that was serialized.</param>
 public virtual void OnAfterSerialize(Type storageType, object instance, ref fsData data)
 {
 }
 public override object CreateInstance(fsData data, Type storageType)
 {
     return(new WeakReference(null));
 }