當前位置: 首頁>>代碼示例>>C#>>正文


C# Global.AddAssemblies方法代碼示例

本文整理匯總了C#中System.Global.AddAssemblies方法的典型用法代碼示例。如果您正苦於以下問題:C# Global.AddAssemblies方法的具體用法?C# Global.AddAssemblies怎麽用?C# Global.AddAssemblies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Global的用法示例。


在下文中一共展示了Global.AddAssemblies方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Load


//.........這裏部分代碼省略.........
            //         asmRef.Location = <the right place>;
            //     }
            //     SystemAssemblyLocation.Location = <the right place>;
            //     SystemXmlAssemblyLocation.Location = <the right place>;
            // 
            // But so far that doesn't seem necessary

            CCI.SystemTypes.Initialize(false, true, resolver);

            // ----------------------------------------
            // Account for mscorlib being loaded
            // ----------------------------------------
            var mscorlib = CCI.SystemTypes.SystemAssembly;
            if (mscorlib == null || mscorlib.Directory == null)
            {
                log(new UnloadableMSCorLibMessage(frameworkDir));
                throw new ExitException();
            }

            var mscorlibName = StrongAssemblyNameFromCCIAssembly(mscorlib);
            fileNameToStrongName[mscorlibCanonicalName] = mscorlibName;
            strongNameToInfo.Add(mscorlibName, new AssemblyInfo { Assembly = mscorlib, FileName = mscorlibCanonicalName });
            log(new LoadedAssemblyMessage(mscorlib.StrongName, mscorlibCanonicalName));


            Void = ResolveCCIType(mscorlib, "System", "Void");
            ValueType = ResolveCCIType(mscorlib, "System", "ValueType");
            Enum = ResolveCCIType(mscorlib, "System", "Enum");

            global = new Global(mscorlibName);

            // The global environment is now ready for use...

            // ----------------------------------------
            // Load the remaining registered assemblies
            // ----------------------------------------
            var pending = new List<string>();
            foreach (var kv in fileNameToStrongName)
            {
                if (kv.Value == null)
                    pending.Add(kv.Key);
                // else: must have been mscorlib, which we loaded above
            }
            foreach (var canonicalFileName in pending)
            {
                var assembly = CCI.AssemblyNode.GetAssembly(canonicalFileName, null, false, true, true);
                if (assembly == null)
                {
                    log(new UnloadableAssemblyMessage(canonicalFileName));
                    throw new ExitException();
                }
                var sn = StrongAssemblyNameFromCCIAssembly(assembly);
                var info = default(AssemblyInfo);
                if (strongNameToInfo.TryGetValue(sn, out info))
                {
                    log(new DuplicateAssemblyStrongNameMessage(canonicalFileName, sn.ToString(), info.FileName));
                    throw new ExitException();
                }
                log(new LoadedAssemblyMessage(sn.ToString(), canonicalFileName));
                fileNameToStrongName[canonicalFileName] = sn;
                strongNameToInfo.Add(sn, new AssemblyInfo { Assembly = assembly, FileName = canonicalFileName });
                assembly.AssemblyReferenceResolution += resolver;
            }

            // ----------------------------------------
            // Convert all assemblies. Since we visit all assemblies and types this will also check that
            // all assembly references resolved to valid assemblies.
            // ----------------------------------------

            // We use the global environment for the first time here...

            var assemblies = new List<AssemblyDef>();
            foreach (var kv in strongNameToInfo)
            {
                try
                {
                    assemblies.Add(AssemblyDefFromCCIAssembly(kv.Value.Assembly));
                    log(new ResolvedAssemblyMessage(kv.Key.ToString(), kv.Value.FileName));
                }
                catch (InvalidOperationException)
                {
                    log(new UnresolvableAssemblyMessage(kv.Key.ToString(), kv.Value.FileName));
                    throw new ExitException();
                }
            }

            global.AddAssemblies(assemblies);

            // ----------------------------------------
            // Teardown CCI
            // ----------------------------------------

            cciQualifiedTypeNameCache.Clear();
            foreach (var kv in strongNameToInfo)
                kv.Value.Assembly.Dispose();
            strongNameToInfo.Clear();
            CCI.TargetPlatform.Clear();

            return global;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:101,代碼來源:CCILoader.cs


注:本文中的System.Global.AddAssemblies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。