Exemple #1
0
        public override void Init(IScriptExportManager manager)
        {
            m_template = manager.RetrieveType(Type.ElementType);

            int argumentCount = MonoUtils.GetGenericArgumentCount(Type);

            m_arguments = new ScriptExportType[argumentCount];
            for (int i = Type.GenericArguments.Count - argumentCount, j = 0; i < Type.GenericArguments.Count; i++, j++)
            {
                TypeReference argument = Type.GenericArguments[i];
                m_arguments[j] = manager.RetrieveType(argument);
            }

            if (Type.DeclaringType != null)
            {
                if (Type.DeclaringType.HasGenericParameters)
                {
                    IEnumerable <TypeReference> nestArguments = Type.GenericArguments.Take(Type.GenericArguments.Count - argumentCount);
                    GenericInstanceType         nestInstance  = MonoUtils.CreateGenericInstance(Type.DeclaringType, nestArguments);
                    m_nest = manager.RetrieveType(nestInstance);
                }
                else
                {
                    m_nest = manager.RetrieveType(Type.DeclaringType);
                }
            }
        }
Exemple #2
0
 public static string GetNestedName(TypeReference type, string typeName)
 {
     if (type.IsGenericParameter)
     {
         return(typeName);
     }
     if (type.IsNested)
     {
         string declaringName;
         if (type.IsGenericInstance)
         {
             GenericInstanceType generic           = (GenericInstanceType)type;
             int argumentCount                     = MonoUtils.GetGenericArgumentCount(generic);
             List <TypeReference> genericArguments = new List <TypeReference>(generic.GenericArguments.Count - argumentCount);
             for (int i = 0; i < generic.GenericArguments.Count - argumentCount; i++)
             {
                 genericArguments.Add(generic.GenericArguments[i]);
             }
             declaringName = GetNestedGenericName(type.DeclaringType, genericArguments);
         }
         else if (type.HasGenericParameters)
         {
             List <TypeReference> genericArguments = new List <TypeReference>(type.GenericParameters);
             declaringName = GetNestedGenericName(type.DeclaringType, genericArguments);
         }
         else
         {
             declaringName = GetNestedName(type.DeclaringType);
         }
         return($"{declaringName}.{typeName}");
     }
     return(typeName);
 }