SerializeType() private method

private SerializeType ( System type ) : string
type System
return string
示例#1
0
        /// <summary>
        /// Writes an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
        /// </summary>
        public static void WriteNetObject(object value, ProtoWriter dest, int key, NetObjectOptions options)
        {
#if FEAT_IKVM
            throw new NotSupportedException();
#else
            Helpers.DebugAssert(value != null);
            bool dynamicType         = (options & NetObjectOptions.DynamicType) != 0,
                 asReference         = (options & NetObjectOptions.AsReference) != 0;
            WireType     wireType    = dest.WireType;
            SubItemToken token       = ProtoWriter.StartSubItem(null, dest);
            bool         writeObject = true;
            if (asReference)
            {
                bool existing;
                int  objectKey = dest.NetCache.AddObjectKey(value, out existing);
                ProtoWriter.WriteFieldHeader(existing ? FieldExistingObjectKey : FieldNewObjectKey, WireType.Variant, dest);
                ProtoWriter.WriteInt32(objectKey, dest);
                if (existing)
                {
                    writeObject = false;
                }
            }

            if (writeObject)
            {
                if (dynamicType)
                {
                    bool existing;
                    Type type = value.GetType();

                    if (!(value is string))
                    {
                        key = dest.GetTypeKey(ref type);
                        if (key < 0)
                        {
                            throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
                        }
                    }
                    int typeKey = dest.NetCache.AddObjectKey(type, out existing);
                    ProtoWriter.WriteFieldHeader(existing ? FieldExistingTypeKey : FieldNewTypeKey, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(typeKey, dest);
                    if (!existing)
                    {
                        ProtoWriter.WriteFieldHeader(FieldTypeName, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                }
                ProtoWriter.WriteFieldHeader(FieldObject, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else
                {
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
#endif
        }
示例#2
0
        public static void WriteNetObject(object value, ProtoWriter dest, int key, BclHelpers.NetObjectOptions options)
        {
            bool flag;
            bool flag1;

            if (dest == null)
            {
                throw new ArgumentNullException("dest");
            }
            bool         flag2        = (byte)(options & BclHelpers.NetObjectOptions.DynamicType) != 0;
            bool         flag3        = (byte)(options & BclHelpers.NetObjectOptions.AsReference) != 0;
            WireType     wireType     = dest.WireType;
            SubItemToken subItemToken = ProtoWriter.StartSubItem(null, dest);
            bool         flag4        = true;

            if (flag3)
            {
                int num = dest.NetCache.AddObjectKey(value, out flag);
                ProtoWriter.WriteFieldHeader((flag ? 1 : 2), WireType.Variant, dest);
                ProtoWriter.WriteInt32(num, dest);
                if (flag)
                {
                    flag4 = false;
                }
            }
            if (flag4)
            {
                if (flag2)
                {
                    Type type = value.GetType();
                    if (!(value is string))
                    {
                        key = dest.GetTypeKey(ref type);
                        if (key < 0)
                        {
                            throw new InvalidOperationException(string.Concat("Dynamic type is not a contract-type: ", type.Name));
                        }
                    }
                    int num1 = dest.NetCache.AddObjectKey(type, out flag1);
                    ProtoWriter.WriteFieldHeader((flag1 ? 3 : 4), WireType.Variant, dest);
                    ProtoWriter.WriteInt32(num1, dest);
                    if (!flag1)
                    {
                        ProtoWriter.WriteFieldHeader(8, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                }
                ProtoWriter.WriteFieldHeader(10, wireType, dest);
                if (!(value is string))
                {
                    ProtoWriter.WriteObject(value, key, dest);
                }
                else
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
            }
            ProtoWriter.EndSubItem(subItemToken, dest);
        }
 /// <summary>
 /// Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
 /// </summary>
 public static void WriteType(System.Type value, ProtoWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     WriteString(writer.SerializeType(value), writer);
 }
示例#4
0
        public static void WriteNetObject(object value, ProtoWriter dest, int key, NetObjectOptions options)
        {
            if (dest == null)
            {
                throw new ArgumentNullException("dest");
            }
            bool         flag     = (options & NetObjectOptions.DynamicType) != 0;
            bool         num      = (options & NetObjectOptions.AsReference) != 0;
            WireType     wireType = dest.WireType;
            SubItemToken token    = ProtoWriter.StartSubItem(null, dest);
            bool         flag2    = true;

            if (num)
            {
                bool existing;
                int  value2 = dest.NetCache.AddObjectKey(value, out existing);
                ProtoWriter.WriteFieldHeader(existing ? 1 : 2, WireType.Variant, dest);
                ProtoWriter.WriteInt32(value2, dest);
                if (existing)
                {
                    flag2 = false;
                }
            }
            if (flag2)
            {
                if (flag)
                {
                    Type type = value.GetType();
                    if (!(value is string))
                    {
                        key = dest.GetTypeKey(ref type);
                        if (key < 0)
                        {
                            throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
                        }
                    }
                    bool existing2;
                    int  value3 = dest.NetCache.AddObjectKey(type, out existing2);
                    ProtoWriter.WriteFieldHeader(existing2 ? 3 : 4, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(value3, dest);
                    if (!existing2)
                    {
                        ProtoWriter.WriteFieldHeader(8, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                }
                ProtoWriter.WriteFieldHeader(10, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else
                {
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
        }
示例#5
0
        public static void WriteNetObject(object value, ProtoWriter dest, int key, BclHelpers.NetObjectOptions options)
        {
            if (dest == null)
            {
                throw new ArgumentNullException("dest");
            }
            bool         flag     = (byte)(options & BclHelpers.NetObjectOptions.DynamicType) != 0;
            bool         flag2    = (byte)(options & BclHelpers.NetObjectOptions.AsReference) != 0;
            WireType     wireType = dest.WireType;
            SubItemToken token    = ProtoWriter.StartSubItem(null, dest);
            bool         flag3    = true;

            if (flag2)
            {
                bool flag4;
                int  value2 = dest.NetCache.AddObjectKey(value, out flag4);
                ProtoWriter.WriteFieldHeader((!flag4) ? 2 : 1, WireType.Variant, dest);
                ProtoWriter.WriteInt32(value2, dest);
                if (flag4)
                {
                    flag3 = false;
                }
            }
            if (flag3)
            {
                if (flag)
                {
                    Type type = value.GetType();
                    if (!(value is string))
                    {
                        key = dest.GetTypeKey(ref type);
                        if (key < 0)
                        {
                            throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.get_Name());
                        }
                    }
                    bool flag5;
                    int  value3 = dest.NetCache.AddObjectKey(type, out flag5);
                    ProtoWriter.WriteFieldHeader((!flag5) ? 4 : 3, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(value3, dest);
                    if (!flag5)
                    {
                        ProtoWriter.WriteFieldHeader(8, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                }
                ProtoWriter.WriteFieldHeader(10, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else
                {
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
        }
示例#6
0
        /// <summary>
        /// Writes an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
        /// </summary>
        public static void WriteNetObject(object value, ProtoWriter dest, int key, bool dynamicType, bool asReference)
        {
            Helpers.DebugAssert(value != null);
            WireType     wireType    = dest.WireType;
            SubItemToken token       = ProtoWriter.StartSubItem(null, dest);
            bool         writeObject = true;

            if (asReference)
            {
                bool existing;
                int  objectKey = dest.NetCache.AddObjectKey(value, out existing);
                ProtoWriter.WriteFieldHeader(existing ? FieldExistingObjectKey : FieldNewObjectKey, WireType.Variant, dest);
                ProtoWriter.WriteInt32(objectKey, dest);
                if (existing)
                {
                    writeObject = false;
                }
            }

            if (writeObject)
            {
                if (dynamicType)
                {
                    bool existing;
                    Type type = value.GetType();
                    key = dest.GetTypeKey(ref type);
                    int typeKey = dest.NetCache.AddObjectKey(type, out existing);
                    ProtoWriter.WriteFieldHeader(existing ? FieldExistingTypeKey : FieldNewTypeKey, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(typeKey, dest);
                    if (!existing)
                    {
                        ProtoWriter.WriteFieldHeader(FieldTypeName, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                }
                ProtoWriter.WriteFieldHeader(FieldObject, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else
                {
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
        }
示例#7
0
        /// <summary>
        /// Writes an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
        /// </summary>
        public static void WriteNetObject(object value, ProtoWriter dest, int key, NetObjectOptions options)
        {
#if FEAT_IKVM
            throw new NotSupportedException();
#else
            if (dest == null) throw new ArgumentNullException("dest");
            bool dynamicType = (options & NetObjectOptions.DynamicType) != 0,
                 asReference = (options & NetObjectOptions.AsReference) != 0;
            WireType wireType = dest.WireType;
            SubItemToken token = ProtoWriter.StartSubItem(null, dest);
            bool writeObject = true;
            if (asReference)
            {
                bool existing;
                int objectKey = dest.NetCache.AddObjectKey(value, out existing);
                ProtoWriter.WriteFieldHeader(existing ? FieldExistingObjectKey : FieldNewObjectKey, WireType.Variant, dest);
                ProtoWriter.WriteInt32(objectKey, dest);
                if (existing)
                {
                    writeObject = false;
                }
            }

            if (writeObject)
            {
                if (dynamicType)
                {
                    bool existing;
                    Type type = value.GetType();

                    if (!(value is string))
                    {
                        key = dest.GetTypeKey(ref type);
                        if (key < 0) throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
                    }
                    int typeKey = dest.NetCache.AddObjectKey(type, out existing);
                    ProtoWriter.WriteFieldHeader(existing ? FieldExistingTypeKey : FieldNewTypeKey, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(typeKey, dest);
                    if (!existing)
                    {
                        ProtoWriter.WriteFieldHeader(FieldTypeName, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                    
                }
                ProtoWriter.WriteFieldHeader(FieldObject, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else { 
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
#endif
        }
示例#8
0
 /// <summary>
 /// Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
 /// </summary>
 public static void WriteType(System.Type value, ProtoWriter writer)
 {
     if (writer == null) throw new ArgumentNullException("writer");
     WriteString(writer.SerializeType(value), writer);
 }
示例#9
0
        /// <summary>
        /// Writes an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
        /// </summary>
        public static void WriteNetObject(object value, ProtoWriter dest, int key, NetObjectOptions options)
        {
            Helpers.DebugAssert(value != null);
            bool dynamicType = (options & NetObjectOptions.DynamicType) != 0,
                 asReference = (options & NetObjectOptions.AsReference) != 0;
            WireType wireType = dest.WireType;
            SubItemToken token = ProtoWriter.StartSubItem(null, dest);
            bool writeObject = true;
            if (asReference)
            {
                bool existing;
                int objectKey = dest.NetCache.AddObjectKey(value, out existing);
                ProtoWriter.WriteFieldHeader(existing ? FieldExistingObjectKey : FieldNewObjectKey, WireType.Variant, dest);
                ProtoWriter.WriteInt32(objectKey, dest);
                if (existing)
                {
                    writeObject = false;
                }
            }

            if (writeObject)
            {
                if (dynamicType)
                {
                    bool existing;
                    Type type = value.GetType();
                    key = dest.GetTypeKey(ref type);
                    int typeKey = dest.NetCache.AddObjectKey(type, out existing);
                    ProtoWriter.WriteFieldHeader(existing ? FieldExistingTypeKey : FieldNewTypeKey, WireType.Variant, dest);
                    ProtoWriter.WriteInt32(typeKey, dest);
                    if (!existing)
                    {
                        ProtoWriter.WriteFieldHeader(FieldTypeName, WireType.String, dest);
                        ProtoWriter.WriteString(dest.SerializeType(type), dest);
                    }
                    
                }
                ProtoWriter.WriteFieldHeader(FieldObject, wireType, dest);
                if (value is string)
                {
                    ProtoWriter.WriteString((string)value, dest);
                }
                else { 
                    ProtoWriter.WriteObject(value, key, dest);
                }
            }
            ProtoWriter.EndSubItem(token, dest);
        }
示例#10
0
 /// <summary>
 /// Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
 /// </summary>
 public static void WriteType(System.Type value, ProtoWriter writer)
 {
     WriteString(writer.SerializeType(value), writer);
 }
示例#11
0
 /// <summary>
 /// Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
 /// </summary>
 public static void WriteType(Type value, ProtoWriter writer)
 {
     WriteString(writer.SerializeType(value), writer);
 }
示例#12
0
 public static void WriteNetObject(object value, ProtoWriter dest, int key, BclHelpers.NetObjectOptions options)
 {
     if (dest == null)
     {
         throw new ArgumentNullException("dest");
     }
     bool flag = (byte)(options & BclHelpers.NetObjectOptions.DynamicType) != 0;
     bool flag2 = (byte)(options & BclHelpers.NetObjectOptions.AsReference) != 0;
     WireType wireType = dest.WireType;
     SubItemToken token = ProtoWriter.StartSubItem(null, dest);
     bool flag3 = true;
     if (flag2)
     {
         bool flag4;
         int value2 = dest.NetCache.AddObjectKey(value, out flag4);
         ProtoWriter.WriteFieldHeader((!flag4) ? 2 : 1, WireType.Variant, dest);
         ProtoWriter.WriteInt32(value2, dest);
         if (flag4)
         {
             flag3 = false;
         }
     }
     if (flag3)
     {
         if (flag)
         {
             Type type = value.GetType();
             if (!(value is string))
             {
                 key = dest.GetTypeKey(ref type);
                 if (key < 0)
                 {
                     throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
                 }
             }
             bool flag5;
             int value3 = dest.NetCache.AddObjectKey(type, out flag5);
             ProtoWriter.WriteFieldHeader((!flag5) ? 4 : 3, WireType.Variant, dest);
             ProtoWriter.WriteInt32(value3, dest);
             if (!flag5)
             {
                 ProtoWriter.WriteFieldHeader(8, WireType.String, dest);
                 ProtoWriter.WriteString(dest.SerializeType(type), dest);
             }
         }
         ProtoWriter.WriteFieldHeader(10, wireType, dest);
         if (value is string)
         {
             ProtoWriter.WriteString((string)value, dest);
         }
         else
         {
             ProtoWriter.WriteObject(value, key, dest);
         }
     }
     ProtoWriter.EndSubItem(token, dest);
 }