Example #1
0
        private void WriteCustomAttributeValue(TypeReference type, object value)
        {
            ElementType etype       = type.etype;
            ElementType elementType = etype;

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

            if (elementType != ElementType.None)
            {
                if (elementType == ElementType.Object)
                {
                    this.WriteElementType(ElementType.Boxed);
                    return;
                }
                this.WriteElementType(etype);
                return;
            }
            else
            {
                if (type.IsTypeOf("System", "Type"))
                {
                    this.WriteElementType(ElementType.Type);
                    return;
                }
                this.WriteElementType(ElementType.Enum);
                this.WriteTypeReference(type);
                return;
            }
        }
Example #3
0
        private object ReadCustomAttributeElementValue(TypeReference type)
        {
            ElementType etype       = type.etype;
            ElementType elementType = etype;

            if (elementType != ElementType.None)
            {
                if (elementType == ElementType.String)
                {
                    return(this.ReadUTF8String());
                }
                return(this.ReadPrimitiveValue(etype));
            }
            else
            {
                if (type.IsTypeOf("System", "Type"))
                {
                    return(this.ReadTypeReference());
                }
                return(this.ReadCustomAttributeEnum(type));
            }
        }