Пример #1
0
        private void WriteCustomAttributeValue(TypeReference type, object value)
        {
            ElementType etype = type.etype;

            if (etype == ElementType.None)
            {
                if (type.IsTypeOf("System", "Type"))
                {
                    this.WriteTypeReference((TypeReference)value);
                }
                else
                {
                    this.WriteCustomAttributeEnumValue(type, value);
                }
            }
            else if (etype != ElementType.String)
            {
                this.WritePrimitiveValue(value);
            }
            else
            {
                string str = (string)value;
                if (str == null)
                {
                    base.WriteByte(0xff);
                }
                else
                {
                    this.WriteUTF8String(str);
                }
            }
        }
Пример #2
0
        private void WriteCustomAttributeFieldOrPropType(TypeReference type)
        {
            if (type.IsArray)
            {
                ArrayType arrayType = (ArrayType)type;
                this.WriteElementType(ElementType.SzArray);
                this.WriteCustomAttributeFieldOrPropType(arrayType.ElementType);
                return;
            }
            ElementType elementType = type.etype;

            if (elementType != ElementType.None)
            {
                if (elementType == ElementType.Object)
                {
                    this.WriteElementType(ElementType.Boxed);
                    return;
                }
                this.WriteElementType(elementType);
                return;
            }
            if (type.IsTypeOf("System", "Type"))
            {
                this.WriteElementType(ElementType.Type);
                return;
            }
            this.WriteElementType(ElementType.Enum);
            this.WriteTypeReference(type);
        }
Пример #3
0
 private void WriteCustomAttributeFieldOrPropType(TypeReference type)
 {
     if (type.IsArray)
     {
         ArrayType type2 = (ArrayType)type;
         this.WriteElementType(ElementType.SzArray);
         this.WriteCustomAttributeFieldOrPropType(type2.ElementType);
     }
     else
     {
         ElementType etype = type.etype;
         ElementType type4 = etype;
         if (type4 != ElementType.None)
         {
             if (type4 == ElementType.Object)
             {
                 this.WriteElementType(ElementType.Boxed);
             }
             else
             {
                 this.WriteElementType(etype);
             }
         }
         else if (type.IsTypeOf("System", "Type"))
         {
             this.WriteElementType(ElementType.Type);
         }
         else
         {
             this.WriteElementType(ElementType.Enum);
             this.WriteTypeReference(type);
         }
     }
 }
Пример #4
0
        private object ReadCustomAttributeElementValue(TypeReference type)
        {
            ElementType etype = type.etype;
            ElementType type3 = etype;

            return((type3 == ElementType.None) ? (!type.IsTypeOf("System", "Type") ? this.ReadCustomAttributeEnum(type) : this.ReadTypeReference()) : ((type3 != ElementType.String) ? this.ReadPrimitiveValue(etype) : this.ReadUTF8String()));
        }
Пример #5
0
        private void WriteCustomAttributeFieldOrPropType(TypeReference type)
        {
            if (type.IsArray)
            {
                ArrayType arrayType = (ArrayType)type;
                WriteElementType(ElementType.SzArray);
                WriteCustomAttributeFieldOrPropType(arrayType.ElementType);
            }
            else
            {
                ElementType etype = type.etype;
                switch (etype)
                {
                case ElementType.Object:
                    WriteElementType(ElementType.Boxed);
                    break;

                case ElementType.None:
                    if (type.IsTypeOf("System", "Type"))
                    {
                        WriteElementType(ElementType.Type);
                    }
                    else
                    {
                        WriteElementType(ElementType.Enum);
                        WriteTypeReference(type);
                    }
                    break;

                default:
                    WriteElementType(etype);
                    break;
                }
            }
        }
Пример #6
0
        private void WriteCustomAttributeValue(TypeReference type, object value)
        {
            switch (type.etype)
            {
            case ElementType.String:
            {
                string text = (string)value;
                if (text == null)
                {
                    base.WriteByte(byte.MaxValue);
                }
                else
                {
                    WriteUTF8String(text);
                }
                break;
            }

            case ElementType.None:
                if (type.IsTypeOf("System", "Type"))
                {
                    WriteTypeReference((TypeReference)value);
                }
                else
                {
                    WriteCustomAttributeEnumValue(type, value);
                }
                break;

            default:
                WritePrimitiveValue(value);
                break;
            }
        }
Пример #7
0
        private object ReadCustomAttributeElementValue(TypeReference type)
        {
            ElementType elementType = type.etype;

            if (elementType != ElementType.None)
            {
                if (elementType == ElementType.String)
                {
                    return(this.ReadUTF8String());
                }
                return(this.ReadPrimitiveValue(elementType));
            }
            if (type.IsTypeOf("System", "Type"))
            {
                return(this.ReadTypeReference());
            }
            return(this.ReadCustomAttributeEnum(type));
        }
Пример #8
0
        private object ReadCustomAttributeElementValue(TypeReference type)
        {
            ElementType etype = type.etype;

            switch (etype)
            {
            case ElementType.String:
                return(ReadUTF8String());

            case ElementType.None:
                if (type.IsTypeOf("System", "Type"))
                {
                    return(ReadTypeReference());
                }
                return(ReadCustomAttributeEnum(type));

            default:
                return(ReadPrimitiveValue(etype));
            }
        }