Ejemplo n.º 1
0
        /// <summary>读取Type</summary>
        /// <returns></returns>
        protected override Type OnReadType()
        {
            if (Settings.SplitComplexType)
            {
                Type type = null;
                BinarySettings.TypeKinds kind = (BinarySettings.TypeKinds)ReadByte();

                WriteLog("ReadType", kind);

                switch (kind)
                {
                case BinarySettings.TypeKinds.Normal:
                    return(base.OnReadType());

                case BinarySettings.TypeKinds.Array:
                    Int32 rank = ReadInt32();
                    return(ReadType().MakeArrayType(rank));

                case BinarySettings.TypeKinds.Nested:
                    return(ReadType().GetNestedType(ReadString(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance));

                //type = ReadType();
                //type = type.GetNestedType(ReadString(), BindingFlags.Public | BindingFlags.NonPublic);
                //return type;

                case BinarySettings.TypeKinds.Generic:
                    type = ReadType();
                    Type[] ts = type.GetGenericArguments();
                    for (int i = 0; i < ts.Length; i++)
                    {
                        ts[i] = ReadType();
                    }
                    return(type.MakeGenericType(ts));

                default:
                    break;
                }
            }

            return(base.OnReadType());
        }
Ejemplo n.º 2
0
 void WriteTypeKind(BinarySettings.TypeKinds kind)
 {
     WriteLog("WriteTypeKind", kind);
     WriteValue((Byte)kind);
 }