Exemplo n.º 1
0
        public void ProcessPrimitives <[Primitive] T>(IReadOnlyValueDescriptor <T> descriptor)
        {
            var value = descriptor.Get();

            // _store.Set("Type", value.GetType());
            _store.Set(descriptor.StateMember.Name, value);
        }
        public void ProcessCollection <T>(IReadOnlyValueDescriptor <ICollection <T> > descriptor)
        {
            int count;
            var collection = descriptor.Get();

            if (!_store.TryGet(descriptor.StateMember.Name + ".Count", out count))
            {
                return;
            }


            var temp = _store;

            for (int i = 0; i < count; i++)
            {
                var strongBox = new StrongBox <T>(default(T));

                descriptor.Route(new StrongBoxStateMember <T>(strongBox, "Item_" + i),
                                 typeof(T), strongBox, false);

                collection.Add(strongBox.Value);
            }

            _store = temp;
        }
Exemplo n.º 3
0
        private void WritePropertyName <T>(IReadOnlyValueDescriptor <T> descriptor)
        {
            Type type = typeof(T);

            WritePropertyName((IValueDescriptor)descriptor);
            _writer.WriteAttributeString("Type", type.AssemblyQualifiedName);
        }
Exemplo n.º 4
0
        public virtual void Process <TRuntime>
            (IReadOnlyValueDescriptor <TRuntime> descriptor)
            where TRuntime : T
        {
            T runtime = descriptor.Get();

            _callback(runtime);
        }
Exemplo n.º 5
0
        public void ProcessGeneric <T>(IReadOnlyValueDescriptor <T> descriptor)
        {
            WritePropertyName(descriptor);

            descriptor.Climb();

            EndWritePropertyName();
        }
Exemplo n.º 6
0
        public void Process <T>(IReadOnlyValueDescriptor <T> descriptor)
        {
            T objectToSerialize = descriptor.Get();

            var runtimeType = objectToSerialize.GetType();

            BinaryStateMember member = descriptor.StateMember as BinaryStateMember;

            WriteAssemblyQualifiedNameIfNeeded(member, runtimeType);

            descriptor.Climb();
        }
Exemplo n.º 7
0
        public void Process <T>(IReadOnlyValueDescriptor <T> descriptor)
        {
            var value = descriptor.Get();

            _store.Set("Type", value.GetType().AssemblyQualifiedName);

            var temp = _store;

            _store = _store.GetInner(descriptor.StateMember.Name);

            descriptor.Climb();

            _store = temp;
        }
Exemplo n.º 8
0
        public void ProcessCollection <T>(IReadOnlyValueDescriptor <ICollection <T> > descriptor)
        {
            int i = 0;

            var collection = descriptor.Get();

            _store.Set(descriptor.StateMember.Name + ".Count", collection.Count);

            var temp = _store;

            foreach (var item in collection)
            {
                //_store = temp.GetInner("Item_" + i);
                descriptor.Route(new StaticStateMember(item, "Item_" + i), null, false);

                i++;
            }

            _store = temp;
        }
Exemplo n.º 9
0
 public void ProcessGeneric <TRuntime>
     (IReadOnlyValueDescriptor <TRuntime> descriptor)
 {
     descriptor.Climb();
 }
Exemplo n.º 10
0
        TRuntime IReadOnlyExactValueDescriptor <TRuntime> .Get()
        {
            IReadOnlyValueDescriptor <TRuntime> casted = this;

            return(casted.Get());
        }
Exemplo n.º 11
0
 public void ProcessInt32(IReadOnlyValueDescriptor <int> descriptor)
 {
     WritePropertyName(descriptor);
     _writer.WriteValue(descriptor.Get());
     EndWritePropertyName();
 }
Exemplo n.º 12
0
 public void ProcessString(IReadOnlyValueDescriptor <string> descriptor)
 {
     WritePropertyName(descriptor);
     _writer.WriteValue(descriptor.Get());
     EndWritePropertyName();
 }