コード例 #1
0
        public void Process(IWriteOnlyValueDescriptor <object> descriptor)
        {
            string type;

            if (_store.TryGet("Type", out type))
            {
                descriptor.Route(new MyCustomStateMember((IReflectionStateMember)descriptor.StateMember, Type.GetType(type)), descriptor.Owner, true);
            }
        }
コード例 #2
0
        public void ProcessGeneric <T>(IWriteOnlyValueDescriptor <T> descriptor)
        {
            XElement temp = _reader;

            _reader = _reader.Element(descriptor.StateMember.Name);

            CreateObject(descriptor);

            descriptor.Climb();

            _reader = temp;
        }
コード例 #3
0
        private void CreateObject <T>(IWriteOnlyValueDescriptor <T> descriptor)
        {
            XAttribute attribute = _reader.Attribute("Type");

            if (attribute != null)
            {
                var type = attribute.Value;

                Type instanceType = Type.GetType(type);

                T field =
                    (T)Activator.CreateInstance(instanceType);

                descriptor.Set(field);
            }
        }
コード例 #4
0
        public void Process <T>(IWriteOnlyValueDescriptor <T> descriptor)
        {
            string type;

            if (_store.TryGet("Type", out type))
            {
                var value = (T)Activator.CreateInstance(Type.GetType(type));

                descriptor.Set(value);

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

                descriptor.Climb();

                _store = temp;
            }
        }
コード例 #5
0
 public void ProcessNull <TField>(IWriteOnlyValueDescriptor <TField> descriptor)
 {
     _writer.Write(ReadWriteHeader.Null);
 }
コード例 #6
0
 public void ProcessNull <TField>(IWriteOnlyValueDescriptor <TField> descriptor)
 {
     // Don't climb
 }
コード例 #7
0
 public void ProcessForWrite(IWriteOnlyValueDescriptor <IAsyncResult> descriptor)
 {
     // Sets all fields that are assignable from IAsyncResult to null.
     // (i.e: all fields that have static type object or IAsyncResult)
     descriptor.Set((IAsyncResult)null);
 }
コード例 #8
0
 public void ProcessNull <TField>(IWriteOnlyValueDescriptor <TField> descriptor)
 {
     WritePropertyName(descriptor);
     _writer.WriteValue("null");
     EndWritePropertyName();
 }
コード例 #9
0
 public void ProcessNull <TField>(IWriteOnlyValueDescriptor <TField> descriptor)
 {
     // Does nothing.
 }