Exemple #1
0
        static private void InternalSerializeFields(BinaryWriter writer, object o, Type T)
        {
            // if this is not a root move up to the root
            // so that marshaling includes complete
            // inheritance chain
            if (T.BaseType != null)
            {
                BinarySerializer.InternalSerializeInstance(writer, o, T.BaseType);
            }

            if (T == typeof(string))
            {
                BinarySerializer.InternalSerializeInstance(writer, o, T);
            }
            else
            {
                // unmarshal individual fields
                foreach (FieldInfo info in T.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
                {
                    if (info.FieldType.IsSerializable)
                    {
                        BinarySerializer.InternalSerializeInstance(writer, info.GetValue(o), info.FieldType);
                    }
                }
            }
        }
Exemple #2
0
        static private void SerializeFields(BinaryWriter reader, object o)
        {
            Type t = o.GetType();

            if (t.IsArray)
            {
                BinarySerializer.InternalSerializeInstance(reader, o, t);
            }
            else
            {
                BinarySerializer.InternalSerializeFields(reader, o, t);
            }
        }