Exemplo n.º 1
0
 public object DeserializeBsonValue(TypeConfiguration typeConfig, IEntityHandler parent, string property, BsonDeserializingContext context)
 {
     if (typeConfig.Creator != null)
     {
         var result  = typeConfig.Creator(parent, property);
         var handler = (IEntityHandlerProvider)result;
         handler.GetHandler().DeserializeBson(context);
         return(result);
     }
     else
     {
         return(BsonSerializer.Deserialize(context.BsonReader, typeConfig.Type));
     }
 }
Exemplo n.º 2
0
 public object DeserializeMemeberValue(TypeConfiguration typeConfig, IEntityHandler parent, string property, DeserializingContext context)
 {
     if (typeConfig.IsExternalType)
     {
         return(context.Serializer.Deserialize(context.Reader, typeConfig.Type));
     }
     else if (typeConfig.Creator != null)
     {
         var result  = typeConfig.Creator(parent, property);
         var handler = (IEntityHandlerProvider)result;
         handler.GetHandler().Deserialize(context);
         return(result);
     }
     else
     {
         throw new Exception();
     }
 }
        public DeltaModelInterceptor(TypeConfiguration configuration, DeltaModelManager manager, IEntityHandler parent, string property)
        {
            _typeConfig  = configuration;
            _manager     = manager;
            Parent       = parent;
            NameInParent = property;

            foreach (var prop in configuration.Members)
            {
                if (prop.Value.TypeConfiguration.ValueType != null)
                {
                    _values[prop.Key] = prop.Value.TypeConfiguration.Creator(this, prop.Key);
                }

                if (prop.Value.DefaultValue != null)
                {
                    _values[prop.Key] = prop.Value.DefaultValue;
                }
            }
        }
Exemplo n.º 4
0
 public object DeserializeAndApplyReplace(IEntityHandler parent, string key, object oldValue, TypeConfiguration typeConfig, Change change, DeserializingContext context)
 {
     change.OldValue = oldValue;
     SetObjectParent(oldValue, null, null);
     change.Value = DeserializeMemeberValue(typeConfig, parent, key, context);
     return(change.Value);
 }
Exemplo n.º 5
0
 public object DeserializeAndApplyAdd(IEntityHandler parent, string key, TypeConfiguration typeConfig, Change change, DeserializingContext context)
 {
     change.Value = DeserializeMemeberValue(typeConfig, parent, key, context);
     return(change.Value);
 }
Exemplo n.º 6
0
 public DeltaModelDictionary(IEntityHandler parent, string property, DeltaModelManager manager, TypeConfiguration configuration)
 {
     _manager     = manager;
     _typeConfig  = configuration;
     Parent       = parent;
     NameInParent = property;
 }