GetSortedProperties() public static method

public static GetSortedProperties ( Type t ) : IEnumerable
t System.Type
return IEnumerable
示例#1
0
 public override void Serialize(Stream serializationStream, object obj)
 {
     foreach (var prop in OrderAttribute.GetSortedProperties(obj.GetType()))
     {
         var subType      = prop.PropertyType;
         var subFormatter = _typeFormatterFactory.GetFormatter(subType);
         subFormatter.Serialize(serializationStream, prop.GetValue(obj, null));
     }
 }
示例#2
0
        public override string ToString()
        {
            var result = "{";

            foreach (var prop in OrderAttribute.GetSortedProperties(GetType()))
            {
                result += String.Format("{0}: {1}, ", prop.Name, prop.GetValue(this, null));
            }
            result  = result.TrimEnd(',', ' ');
            result += "}";
            return(result);
        }
示例#3
0
        public override object Deserialize(Stream serializationStream, Type t)
        {
            var ret = t.GetConstructor(new Type[] {}).Invoke(new object[] {});

            foreach (var prop in OrderAttribute.GetSortedProperties(t))
            {
                var subType      = prop.PropertyType;
                var subFormatter = _typeFormatterFactory.GetFormatter(subType);
                var subObj       = subFormatter.Deserialize(serializationStream, subType);
                prop.SetValue(ret, subObj, null);
            }
            return(ret);
        }