当前位置: 首页>>代码示例>>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;未经允许,请勿转载。