当前位置: 首页>>代码示例>>C#>>正文


C# LoadedAssembly.LookupReferencedAssembly方法代码示例

本文整理汇总了C#中ICSharpCode.ILSpy.LoadedAssembly.LookupReferencedAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# LoadedAssembly.LookupReferencedAssembly方法的具体用法?C# LoadedAssembly.LookupReferencedAssembly怎么用?C# LoadedAssembly.LookupReferencedAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.ILSpy.LoadedAssembly的用法示例。


在下文中一共展示了LoadedAssembly.LookupReferencedAssembly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteProjectFile


//.........这里部分代码省略.........
                        w.WriteElementString("TargetFrameworkVersion", "v1.1");
                    } else if (module.IsClr20) {
                        w.WriteElementString("TargetFrameworkVersion", "v2.0");
                        // TODO: Detect when .NET 3.0/3.5 is required
                    } else {
                        w.WriteElementString("TargetFrameworkVersion", "v4.0");
                    }
                }
                w.WriteElementString("WarningLevel", "4");

                w.WriteEndElement(); // </PropertyGroup>

                w.WriteStartElement("PropertyGroup"); // platform-specific
                w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' ");
                w.WriteElementString("PlatformTarget", platformName);
                w.WriteEndElement(); // </PropertyGroup> (platform-specific)

                w.WriteStartElement("PropertyGroup"); // Debug
                w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' ");
                w.WriteElementString("OutputPath", "bin\\Debug\\");
                w.WriteElementString("DebugSymbols", "true");
                w.WriteElementString("DebugType", "full");
                w.WriteElementString("Optimize", "false");
                if (options.DontReferenceStdLib) {
                    w.WriteStartElement("NoStdLib");
                    w.WriteString("true");
                    w.WriteEndElement();
                }
                w.WriteEndElement(); // </PropertyGroup> (Debug)

                w.WriteStartElement("PropertyGroup"); // Release
                w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' ");
                w.WriteElementString("OutputPath", "bin\\Release\\");
                w.WriteElementString("DebugSymbols", "true");
                w.WriteElementString("DebugType", "pdbonly");
                w.WriteElementString("Optimize", "true");
                if (options.DontReferenceStdLib) {
                    w.WriteStartElement("NoStdLib");
                    w.WriteString("true");
                    w.WriteEndElement();
                }
                w.WriteEndElement(); // </PropertyGroup> (Release)

                w.WriteStartElement("ItemGroup"); // References
                foreach (var r in asmRefs) {
                    if (r.Name != "mscorlib") {
                        var asm = assembly.LookupReferencedAssembly(r, module);
                        if (asm != null && ExistsInProject(options, asm.FileName))
                            continue;
                        w.WriteStartElement("Reference");
                        w.WriteAttributeString("Include", IdentifierEscaper.Escape(r.Name));
                        var hintPath = GetHintPath(options, asm);
                        if (hintPath != null) {
                            w.WriteStartElement("HintPath");
                            w.WriteString(hintPath);
                            w.WriteEndElement();
                        }
                        w.WriteEndElement();
                    }
                }
                w.WriteEndElement(); // </ItemGroup> (References)

                foreach (IGrouping<string, string> gr in (from f in files group f.Item2 by f.Item1 into g orderby g.Key select g)) {
                    w.WriteStartElement("ItemGroup");
                    foreach (string file in gr.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)) {
                        w.WriteStartElement(gr.Key);
                        w.WriteAttributeString("Include", file);
                        w.WriteEndElement();
                    }
                    w.WriteEndElement();
                }

                w.WriteStartElement("ItemGroup"); // ProjectReference
                foreach (var r in asmRefs) {
                    var asm = assembly.LookupReferencedAssembly(r, module);
                    if (asm == null)
                        continue;
                    var otherProj = FindOtherProject(options, asm.FileName);
                    if (otherProj != null) {
                        var relPath = GetRelativePath(options.SaveAsProjectDirectory, otherProj.ProjectFileName);
                        w.WriteStartElement("ProjectReference");
                        w.WriteAttributeString("Include", relPath);
                        w.WriteStartElement("Project");
                        w.WriteString(otherProj.ProjectGuid.ToString("B").ToUpperInvariant());
                        w.WriteEndElement();
                        w.WriteStartElement("Name");
                        w.WriteString(IdentifierEscaper.Escape(otherProj.AssemblySimpleName));
                        w.WriteEndElement();
                        w.WriteEndElement();
                    }
                }
                w.WriteEndElement(); // </ItemGroup> (ProjectReference)

                w.WriteStartElement("Import");
                w.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
                w.WriteEndElement();

                w.WriteEndDocument();
            }
        }
开发者ID:se7ensoft,项目名称:dnSpy,代码行数:101,代码来源:CSharpLanguage.cs


注:本文中的ICSharpCode.ILSpy.LoadedAssembly.LookupReferencedAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。