Esempio n. 1
0
        private ExportedClass GetExportedClass(TypeDefinition td, AssemblyExports result)
        {
            ExportedClass exportedClass;

            if (!result.ClassesByName.TryGetValue(td.FullName, out exportedClass))
            {
                TypeDefinition typeDefinition = td;
                while (!typeDefinition.HasGenericParameters && typeDefinition.IsNested)
                {
                    typeDefinition = typeDefinition.DeclaringType;
                }
                exportedClass = new ExportedClass(td.FullName, typeDefinition.HasGenericParameters);
                result.ClassesByName.Add(exportedClass.FullTypeName, exportedClass);
            }
            return(exportedClass);
        }
Esempio n. 2
0
        internal void Refresh()
        {
            int num = InputValues.OrdinalsBase;

            MethodsByExportName.Clear();
            _DuplicateExportMethods.Clear();

            var dictionary = new Dictionary <string, DuplicateExports>();

            foreach (ExportedClass exportedClass in ClassesByName.Values)
            {
                var exportedMethodList = new List <ExportedMethod>(exportedClass.Methods.Count);
                foreach (ExportedMethod method in exportedClass.Methods)
                {
                    DuplicateExports duplicateExports;
                    if (!dictionary.TryGetValue(method.ExportName, out duplicateExports))
                    {
                        method.VTableOffset = num++;
                        MethodsByExportName.Add(method.ExportName, method); // #10 :: MemberName -> ExportName + see DeleteExportAttributeParserAction
                        dictionary.Add(method.ExportName, new DuplicateExports(method));
                    }
                    else
                    {
                        exportedMethodList.Add(method);
                        duplicateExports.Duplicates.Add(method);
                    }
                }

                ExportedClass exportClassCopy = exportedClass;
                exportedMethodList.ForEach((Action <ExportedMethod>)(m => exportClassCopy.Methods.Remove(m)));
                exportedClass.Refresh();
            }

            foreach (DuplicateExports duplicateExports in dictionary.Values)
            {
                if (duplicateExports.Duplicates.Count > 0)
                {
                    this._DuplicateExportMethods.Add(duplicateExports);
                    foreach (ExportedMethod duplicate in (IEnumerable <ExportedMethod>)duplicateExports.Duplicates)
                    {
                        this._DuplicateExportMethodsbyFullName.Add(AssemblyExports.GetKey(duplicate.ExportedClass.FullTypeName, duplicate.MemberName), duplicate);
                    }
                }
            }
            this._DuplicateExportMethods.Sort((Comparison <DuplicateExports>)((l, r) => string.CompareOrdinal(l.UsedExport.ExportName, r.UsedExport.ExportName)));
        }