Exemple #1
0
        private ScriptExportDelegate CreateDelegate(TypeDefinition @delegate)
        {
            ScriptExportMonoDelegate exportDelegate = new ScriptExportMonoDelegate(@delegate);

            m_delegates.Add(exportDelegate.FullName, exportDelegate);
            exportDelegate.Init(this);
            return(exportDelegate);
        }
        public ScriptExportType RetrieveType(TypeReference type)
        {
            if (type.IsArray)
            {
                return(RetrieveArray(type));
            }
            if (type.IsPointer)
            {
                return(RetrievePointer(type));
            }
            if (type.IsGenericInstance)
            {
                return(RetrieveGeneric(type));
            }
            if (type.IsGenericParameter)
            {
                return(CreateType(type, false));
            }

            if (type.Module != null)
            {
                TypeDefinition definition = type.Resolve();
                if (definition != null)
                {
                    if (definition.IsEnum)
                    {
                        return(RetrieveEnum(definition));
                    }
                    if (ScriptExportMonoDelegate.IsDelegate(definition))
                    {
                        return(RetrieveDelegate(definition));
                    }
                }
            }

            string fullname = ScriptExportMonoType.GetFullName(type);

            if (m_types.TryGetValue(fullname, out ScriptExportType exportType))
            {
                return(exportType);
            }
            return(CreateType(type));
        }