Пример #1
0
 /// <summary>
 /// Collects all declared entities in a class
 /// </summary>
 /// <param name="td"></param>
 private static void CollectAllDeclEntitiesInTypeDef(TypeDefinition td)
 {
     //Handle if there are more than one possibility for any generics defined by this td
     if (!PreDefinedGenericClasses.HasMoreOptionsForGenericName(td))
     {
         HandleTypeDef(td);
     }
     else
     {
         foreach (var definedType in PreDefinedGenericClasses.GetAllDefinedTypes(td))
         {
             PreDefinedGenericClasses.recentAccessedTypes.Add(definedType.FullName);
             HandleTypeDef(td);
             PreDefinedGenericClasses.recentAccessedTypes.Remove(definedType.FullName);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Given a method definition, this function gets the generic parameters
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static TypeEx[] GetGenericMethodParameters(IPexComponent host, MethodDefinition mdef)
        {
            TypeEx[] typErr  = new TypeEx[mdef.GenericMethodParametersCount];
            TypeEx   inttype = MetadataFromReflection.GetType(typeof(int));
            int      count   = 0;

            foreach (var genp in mdef.GenericMethodParameters)
            {
                TypeEx predefTypeEx;
                if (PreDefinedGenericClasses.TryGetInstantiatedClass(host, genp.Name, null, out predefTypeEx))
                {
                    typErr[count] = predefTypeEx;
                }
                else
                {
                    typErr[count] = inttype;
                }
                count++;
            }

            return(typErr);
        }