Beispiel #1
0
        /// <summary>
        /// Deserializes the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The serialization context.</param>
        protected virtual object Deserialize(object model, ISerializationContext <TSerializationContextInfo> context)
        {
            Argument.IsNotNull("model", model);
            Argument.IsNotNull("context", context);

            var serializerModifiers = SerializationManager.GetSerializerModifiers(context.ModelType);

            Log.Debug("Using '{0}' serializer modifiers to deserialize type '{1}'", serializerModifiers.Length, context.ModelTypeName);

            var serializingEventArgs = new SerializationEventArgs(context);

            Deserializing?.Invoke(this, serializingEventArgs);

            foreach (var serializerModifier in serializerModifiers)
            {
                serializerModifier.OnDeserializing(context, model);
            }

            BeforeDeserialization(context);

            var deserializedMemberValues = DeserializeMembers(context);

            PopulateModel(context, deserializedMemberValues);

            // Always use the deserialized model (might be a value type)
            model = context.Model;

            AfterDeserialization(context);

            foreach (var serializerModifier in serializerModifiers)
            {
                serializerModifier.OnDeserialized(context, model);
            }

            Deserialized?.Invoke(this, serializingEventArgs);

            return(model);
        }
Beispiel #2
0
 private void OnDeserializing(SerializeEventArgs e)
 {
     Deserializing?.Invoke(this, e);
 }
Beispiel #3
0
 protected virtual void OnDeserializing(SerializeEventArgs e)
 {
     Deserializing?.Invoke(this, e);
     OnModified(EventArgs.Empty);
 }
Beispiel #4
0
 /// <summary>
 /// Triggers the Deserializing event.
 /// </summary>
 /// <param name="ea">The event arguments.</param>
 public virtual void OnDeserializing(SerializingEventArgs ea)
 {
     Deserializing?.Invoke(this, ea);
 }