示例#1
0
        private void SerializeAttributes(ICommodityWriter writer, Type nominalType, object value)
        {
            var serializableMembers = GetSerializableMemberInfos(nominalType);

            foreach (CommodityMemberInfoSerializer memberInfoSerializer in serializableMembers)
            {
                object memberValue = memberInfoSerializer.GetValue(value);
                writer.WriteName(memberInfoSerializer.Name);
                CommoditySerializer.Serialize(writer, memberInfoSerializer.MemberType, memberValue);
            }
        }
示例#2
0
        public void Serialize(ICommodityWriter writer, Type nominalType, object value)
        {
            if (value == null)
            {
                writer.WriteNull();
                return;
            }

            var actualType = value.GetType();

            writer.WriteStartOfObject();
            writer.WriteName("t");
            CommoditySerializer.Serialize(writer, typeof(Type), actualType);
            //writer.WriteType(actualType);
            writer.WriteName("v");
            writer.WriteStartOfObject();
            SerializeAttributes(writer, actualType, value);
            writer.WriteEndOfObject();
            writer.WriteEndOfObject();
        }