protected fsResult CheckKey(fsData data, string key, out fsData subitem)
 {
     return(CheckKey(data.AsDictionary, key, out subitem));
 }
 /// <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);
 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));
 }
 /// <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);
Esempio n. 5
0
 public override object CreateInstance(fsData data, Type storageType)
 {
     return new Bounds();
 }
Esempio n. 6
0
 public override object CreateInstance(fsData data, Type storageType)
 {
     return new GUIStyleState();
 }
Esempio n. 7
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);
        }