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

            MetadataOnlyCommonType.TypeSigToString(pThis, stringBuilder);
            return(stringBuilder.ToString());
        }
Exemple #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));
        }
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            MetadataOnlyCommonType.TypeSigToString(this.ParameterType, stringBuilder);
            stringBuilder.Append(' ');
            return(stringBuilder.ToString());
        }
Exemple #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());
        }
Exemple #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));
     }
 }
Exemple #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);
        }
Exemple #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(")");
        }
Exemple #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("...");
            }
        }
Exemple #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);
        }
Exemple #10
0
 public virtual MetadataOnlyCommonType CreateVectorType(MetadataOnlyCommonType elementType)
 {
     return(new MetadataOnlyVectorType(elementType));
 }
Exemple #11
0
 public virtual MetadataOnlyCommonType CreatePointerType(MetadataOnlyCommonType type)
 {
     return(new MetadataOnlyModifiedType(type, "*"));
 }
Exemple #12
0
 public virtual MetadataOnlyCommonType CreateByRefType(MetadataOnlyCommonType type)
 {
     return(new MetadataOnlyModifiedType(type, "&"));
 }
Exemple #13
0
 public virtual MetadataOnlyCommonType CreateArrayType(MetadataOnlyCommonType elementType, int rank)
 {
     return(new MetadataOnlyArrayType(elementType, rank));
 }
Exemple #14
0
 public MetadataOnlyArrayType(MetadataOnlyCommonType elementType, int rank) : base(elementType)
 {
     this.m_rank = rank;
 }
Exemple #15
0
 public MetadataOnlyCommonArrayType(MetadataOnlyCommonType elementType)
 {
     this.m_baseType    = Helpers.Universe(elementType).GetTypeXFromName("System.Array");
     this.m_elementType = elementType;
 }
Exemple #16
0
 public override string ToString()
 {
     return(string.Concat(MetadataOnlyCommonType.TypeSigToString(this.FieldType), " ", this.Name));
 }
Exemple #17
0
 public MetadataOnlyModifiedType(MetadataOnlyCommonType type, string mod)
 {
     this.m_type = type;
     this.m_mod  = mod;
 }
 public MetadataOnlyVectorType(MetadataOnlyCommonType elementType) : base(elementType)
 {
 }