Ejemplo n.º 1
0
        public override void Write(IBinarySerializerForHandle serializer, BinaryWriter writer, object obj)
        {
            var fields = serializer.GetClassFieldInfos(obj.GetType());

            foreach (var field in fields)
            {
                var val = field.GetValue(obj);
                serializer.InternalWrite(writer, val, field.FieldType);
            }
        }
Ejemplo n.º 2
0
        public override object Read(IBinarySerializerForHandle serializer, BinaryReader reader, Type type)
        {
            var    fields = serializer.GetClassFieldInfos(type);
            object obj    = FormatterServices.GetUninitializedObject(type);

            if (type.IsValueType == false)
            {
                serializer.InternalAddReadObjToCacheList(obj);
            }
            foreach (var field in fields)
            {
                var val = serializer.InternalRead(reader, field.FieldType);
                field.SetValue(obj, val);
            }
            return(obj);
        }