예제 #1
0
        public static void Write(IBinaryWriter o, Kernel.Config.FieldLayout d)
        {
            o.Write(d != null);
            if (d == null)
            {
                return;
            }

            Type type = d.GetType();

            if (type == typeof(Kernel.Config.FieldLayoutOfConst))
            {
                o.Write(1);
                FieldLayoutOfConstSerializer.Write(o, d as Kernel.Config.FieldLayoutOfConst);
            }
            else if (type == typeof(Kernel.Config.FieldLayoutOfIntKey))
            {
                o.Write(2);
                FieldLayoutOfIntKeySerializer.Write(o, d as Kernel.Config.FieldLayoutOfIntKey);
            }
            else if (type == typeof(Kernel.Config.FieldLayoutOfStringKey))
            {
                o.Write(3);
                FieldLayoutOfStringKeySerializer.Write(o, d as Kernel.Config.FieldLayoutOfStringKey);
            }
            else
            {
                o.Write(0);
            }
        }
예제 #2
0
        public static Kernel.Config.FieldLayout Read(IBinaryReader o, Kernel.Config.FieldLayout d)
        {
            if (o.ReadBoolean() == false)
            {
                return(null);
            }

            int type = o.ReadInt32();

            switch (type)
            {
            case 1:
                d = FieldLayoutOfConstSerializer.Read(o, d as Kernel.Config.FieldLayoutOfConst);
                break;

            case 2:
                d = FieldLayoutOfIntKeySerializer.Read(o, d as Kernel.Config.FieldLayoutOfIntKey);
                break;

            case 3:
                d = FieldLayoutOfStringKeySerializer.Read(o, d as Kernel.Config.FieldLayoutOfStringKey);
                break;
            }
            return(d);
        }