示例#1
0
        internal static string TypeSigToString(Type pThis)
        {
            StringBuilder stringBuilder = new StringBuilder();

            MetadataOnlyCommonType.TypeSigToString(pThis, stringBuilder);
            return(stringBuilder.ToString());
        }
示例#2
0
        public override string ToString()
        {
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { MetadataOnlyCommonType.TypeSigToString(this.ParameterType), this.Name };
            return(string.Format(invariantCulture, "{0} {1}", str));
        }
示例#3
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            MetadataOnlyCommonType.TypeSigToString(this.ParameterType, stringBuilder);
            stringBuilder.Append(' ');
            return(stringBuilder.ToString());
        }
示例#4
0
        internal static string CommonToString(MethodInfo m)
        {
            StringBuilder stringBuilder = new StringBuilder();

            MetadataOnlyCommonType.TypeSigToString(m.ReturnType, stringBuilder);
            stringBuilder.Append(" ");
            MetadataOnlyMethodInfo.ConstructMethodString(m, stringBuilder);
            return(stringBuilder.ToString());
        }
示例#5
0
 internal static void VerifyNotByRef(MetadataOnlyCommonType type)
 {
     if (type.IsByRef)
     {
         string      str = string.Concat(type.Name, "&");
         CultureInfo invariantCulture       = CultureInfo.InvariantCulture;
         string      cannotFindTypeInModule = MetadataStringTable.CannotFindTypeInModule;
         object[]    objArray = new object[] { str, type.Resolver.ToString() };
         throw new TypeLoadException(string.Format(invariantCulture, cannotFindTypeInModule, objArray));
     }
 }
示例#6
0
        internal static Type[] GetAllInterfacesHelper(MetadataOnlyCommonType type)
        {
            HashSet <Type> types = new HashSet <Type>();

            if (type.BaseType != null)
            {
                types.UnionWith(type.BaseType.GetInterfaces());
            }
            foreach (Type interfacesOnType in type.Resolver.GetInterfacesOnType(type))
            {
                if (types.Contains(interfacesOnType))
                {
                    continue;
                }
                types.Add(interfacesOnType);
                types.UnionWith(interfacesOnType.GetInterfaces());
            }
            Type[] typeArray = new Type[types.Count];
            types.CopyTo(typeArray);
            return(typeArray);
        }
示例#7
0
        private static void ConstructMethodString(MethodInfo m, StringBuilder sb)
        {
            sb.Append(m.Name);
            string str = "";

            if (m.IsGenericMethod)
            {
                sb.Append("[");
                Type[] genericArguments = m.GetGenericArguments();
                for (int i = 0; i < (int)genericArguments.Length; i++)
                {
                    Type type = genericArguments[i];
                    sb.Append(str);
                    MetadataOnlyCommonType.TypeSigToString(type, sb);
                    str = ",";
                }
                sb.Append("]");
            }
            sb.Append("(");
            MetadataOnlyMethodInfo.ConstructParameters(sb, m.GetParameters(), m.CallingConvention);
            sb.Append(")");
        }
示例#8
0
        private static void ConstructParameters(StringBuilder sb, Type[] parameters, CallingConventions callingConvention)
        {
            string str = "";

            for (int i = 0; i < (int)parameters.Length; i++)
            {
                Type type = parameters[i];
                sb.Append(str);
                MetadataOnlyCommonType.TypeSigToString(type, sb);
                if (type.IsByRef)
                {
                    StringBuilder length = sb;
                    length.Length = length.Length - 1;
                    sb.Append(" ByRef");
                }
                str = ", ";
            }
            if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
            {
                sb.Append(str);
                sb.Append("...");
            }
        }
示例#9
0
        internal static PropertyInfo GetPropertyImplHelper(MetadataOnlyCommonType type, string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            if (binder != null)
            {
                throw new NotSupportedException();
            }
            if (modifiers != null && (int)modifiers.Length != 0)
            {
                throw new NotSupportedException();
            }
            StringComparison stringComparison = SignatureUtil.GetStringComparison(bindingAttr);

            PropertyInfo[] properties = type.GetProperties(bindingAttr);
            for (int i = 0; i < (int)properties.Length; i++)
            {
                PropertyInfo propertyInfo = properties[i];
                if (propertyInfo.Name.Equals(name, stringComparison) && (!(returnType != null) || propertyInfo.PropertyType.Equals(returnType)) && MetadataOnlyTypeDef.PropertyParamTypesMatch(propertyInfo, types))
                {
                    return(propertyInfo);
                }
            }
            return(null);
        }
示例#10
0
 public virtual MetadataOnlyCommonType CreateVectorType(MetadataOnlyCommonType elementType)
 {
     return(new MetadataOnlyVectorType(elementType));
 }
示例#11
0
 public virtual MetadataOnlyCommonType CreatePointerType(MetadataOnlyCommonType type)
 {
     return(new MetadataOnlyModifiedType(type, "*"));
 }
示例#12
0
 public virtual MetadataOnlyCommonType CreateByRefType(MetadataOnlyCommonType type)
 {
     return(new MetadataOnlyModifiedType(type, "&"));
 }
示例#13
0
 public virtual MetadataOnlyCommonType CreateArrayType(MetadataOnlyCommonType elementType, int rank)
 {
     return(new MetadataOnlyArrayType(elementType, rank));
 }
示例#14
0
 public MetadataOnlyArrayType(MetadataOnlyCommonType elementType, int rank) : base(elementType)
 {
     this.m_rank = rank;
 }
示例#15
0
 public MetadataOnlyCommonArrayType(MetadataOnlyCommonType elementType)
 {
     this.m_baseType    = Helpers.Universe(elementType).GetTypeXFromName("System.Array");
     this.m_elementType = elementType;
 }
示例#16
0
 public override string ToString()
 {
     return(string.Concat(MetadataOnlyCommonType.TypeSigToString(this.FieldType), " ", this.Name));
 }
示例#17
0
 public MetadataOnlyModifiedType(MetadataOnlyCommonType type, string mod)
 {
     this.m_type = type;
     this.m_mod  = mod;
 }
 public MetadataOnlyVectorType(MetadataOnlyCommonType elementType) : base(elementType)
 {
 }