本文整理汇总了C#中IProjectContent.AddAssemblyReferences方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectContent.AddAssemblyReferences方法的具体用法?C# IProjectContent.AddAssemblyReferences怎么用?C# IProjectContent.AddAssemblyReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectContent
的用法示例。
在下文中一共展示了IProjectContent.AddAssemblyReferences方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSharpCompletion
public CSharpCompletion()
{
projectContent = new CSharpProjectContent();
var assemblies = new List<Assembly>
{
typeof(object).Assembly, // mscorlib
typeof(Uri).Assembly, // System.dll
typeof(Enumerable).Assembly, // System.Core.dll
// typeof(System.Xml.XmlDocument).Assembly, // System.Xml.dll
// typeof(System.Drawing.Bitmap).Assembly, // System.Drawing.dll
// typeof(Form).Assembly, // System.Windows.Forms.dll
// typeof(ICSharpCode.NRefactory.TypeSystem.IProjectContent).Assembly,
};
var unresolvedAssemblies = new IUnresolvedAssembly[assemblies.Count];
Stopwatch total = Stopwatch.StartNew();
Parallel.For(
0, assemblies.Count,
delegate(int i)
{
var loader = new CecilLoader();
var path = assemblies[i].Location;
loader.DocumentationProvider = GetXmlDocumentation(assemblies[i].Location);
unresolvedAssemblies[i] = loader.LoadAssemblyFile(assemblies[i].Location);
});
Debug.WriteLine("Init project content, loading base assemblies: " + total.Elapsed);
projectContent = projectContent.AddAssemblyReferences((IEnumerable<IUnresolvedAssembly>)unresolvedAssemblies);
}
示例2: CSharpCompletion
public CSharpCompletion()
{
projectContent = new CSharpProjectContent();
var assemblies = new List<Assembly>
{
typeof(object).Assembly, // mscorlib
typeof(Uri).Assembly, // System.dll
typeof(Enumerable).Assembly, // System.Core.dll
typeof(System.Xml.XmlDocument).Assembly, // System.Xml.dll
typeof(Sandbox.Common.ObjectBuilders.MyObjectBuilder_AdvancedDoor).Assembly, // SpaceEngineers.ObjectBuilders.dll
typeof(SpaceEngineers.Game.ModAPI.IMyButtonPanel).Assembly, // SpaceEngineers.Game.dll
typeof(Sandbox.MySandboxGame).Assembly, // Sandbox.Game.dll
typeof(Sandbox.ModAPI.MyAPIGateway).Assembly, // Sandbox.Common.dll
typeof(Sandbox.Graphics.GUI.MyGuiSandbox).Assembly, // Sandbox.Graphics.dll
typeof(VRage.MyModelData).Assembly, // VRage.dll
typeof(VRage.Exceptions).Assembly, // VRage.Library.dll
typeof(VRageMath.MathHelper).Assembly, // VRage.Math
typeof(VRage.Game.ObjectBuilders.MyObjectBuilder_EntityStat).Assembly, //VRage.Game
};
var unresolvedAssemblies = new IUnresolvedAssembly[assemblies.Count];
Stopwatch total = Stopwatch.StartNew();
Parallel.For(
0, assemblies.Count,
delegate(int i)
{
var loader = new CecilLoader();
var path = assemblies[i].Location;
loader.DocumentationProvider = GetXmlDocumentation(assemblies[i].Location);
unresolvedAssemblies[i] = loader.LoadAssemblyFile(assemblies[i].Location);
});
Debug.WriteLine("Init project content, loading base assemblies: " + total.Elapsed);
projectContent = projectContent.AddAssemblyReferences((IEnumerable<IUnresolvedAssembly>)unresolvedAssemblies);
}
示例3: Init
void Init(string program)
{
pc = new CSharpProjectContent();
pc = pc.SetAssemblyName("MyAssembly");
unresolvedFile = SyntaxTree.Parse(program, "program.cs").ToTypeSystem();
pc = pc.AddOrUpdateFiles(unresolvedFile);
pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
compilation = pc.CreateCompilation();
}
示例4: MockCSharpProject
public MockCSharpProject(ISolution solution, string name)
: base(new ProjectCreateInformation(solution, FileName.Create("c:\\projects\\" + name + "\\" + name + ".csproj")) {
ProjectName = name,
ActiveProjectConfiguration = new ConfigurationAndPlatform("Debug", "x86"),
TargetFramework = TargetFramework.Net40Client,
})
{
OutputType = OutputType.Library;
projectContent = new CSharpProjectContent().SetAssemblyName(name).SetProjectFileName(this.FileName);
projectContent = projectContent.AddAssemblyReferences(NRefactoryHelper.Corlib);
}
示例5: SetUp
public void SetUp()
{
pc = new CSharpProjectContent();
pc = pc.SetAssemblyName("MyAssembly");
unresolvedFile = SyntaxTree.Parse(program, "program.cs").ToTypeSystem();
pc = pc.AddOrUpdateFiles(unresolvedFile);
pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
compilation = pc.CreateCompilation();
baseClass = compilation.RootNamespace.GetTypeDefinition("Base", 1);
nestedClass = baseClass.NestedTypes.Single();
derivedClass = compilation.RootNamespace.GetTypeDefinition("Derived", 2);
systemClass = compilation.RootNamespace.GetChildNamespace("NS").GetTypeDefinition("System", 0);
}
示例6: SetUp
public void SetUp()
{
pc = new CSharpProjectContent();
pc = pc.SetAssemblyName("MyAssembly");
parsedFile = new CSharpParser().Parse(new StringReader(program), "program.cs").ToTypeSystem();
pc = pc.UpdateProjectContent(null, parsedFile);
pc = pc.AddAssemblyReferences(new [] { CecilLoaderTests.Mscorlib });
compilation = pc.CreateCompilation();
baseClass = compilation.RootNamespace.GetTypeDefinition("Base", 1);
nestedClass = baseClass.NestedTypes.Single();
derivedClass = compilation.RootNamespace.GetTypeDefinition("Derived", 2);
systemClass = compilation.FindType("NS.System, MyAssembly").GetDefinition();
}
示例7: Minifier
public Minifier(MinifierOptions options = null, string[] ignoredIdentifiers = null, string[] ignoredComments = null)
{
Options = options ?? new MinifierOptions();
_projectContent = new CSharpProjectContent();
var assemblies = new List<Assembly>
{
typeof(object).Assembly, // mscorlib
typeof(Uri).Assembly, // System.dll
typeof(Enumerable).Assembly, // System.Core.dll
};
var unresolvedAssemblies = new IUnresolvedAssembly[assemblies.Count];
Parallel.For(
0, assemblies.Count,
delegate (int i)
{
var loader = new CecilLoader();
var path = assemblies[i].Location;
unresolvedAssemblies[i] = loader.LoadAssemblyFile(assemblies[i].Location);
});
_projectContent = _projectContent.AddAssemblyReferences((IEnumerable<IUnresolvedAssembly>)unresolvedAssemblies);
IgnoredIdentifiers = ignoredIdentifiers == null ? new List<string>() : ignoredIdentifiers.ToList();
IgnoredComments = new List<string>();
if (ignoredComments != null)
foreach (var comment in ignoredComments)
{
var str = comment;
if (str.StartsWith("//"))
str = str.Substring("//".Length);
else if (str.StartsWith("/*") && str.EndsWith("*/"))
str = str.Substring("/*".Length, str.Length - "/*".Length - "*/".Length);
if (!IgnoredComments.Contains(str))
IgnoredComments.Add(str);
}
}
示例8: AddAllProjectReferences
private static IProjectContent AddAllProjectReferences(Project msbuildProject, IProjectContent pc)
{
foreach (var item in msbuildProject.GetItems("ProjectReference"))
{
var referencedFileName = Path.Combine(msbuildProject.DirectoryPath, item.EvaluatedInclude);
referencedFileName = Path.GetFullPath(referencedFileName);
pc = pc.AddAssemblyReferences(new[] {new ProjectReference(referencedFileName)});
}
return pc;
}
示例9: AddAllAssemblyReferences
private IProjectContent AddAllAssemblyReferences(CSharpSolution solution, Project msbuildProject, IProjectContent pc)
{
foreach (var assemblyFile in ResolveAssemblyReferences(msbuildProject))
{
var assembly = solution.LoadAssembly(assemblyFile);
pc = pc.AddAssemblyReferences(new[] { assembly });
}
return pc;
}
示例10: CSharpProject
public CSharpProject(
ICSharpFileFactory cSharpFileFactory,
MicrosoftBuildProject msBuildProject,
string title)
{
Title = title;
AssemblyName = msBuildProject.AssemblyName;
FileName = msBuildProject.FileName;
CompilerSettings =
#region new CompilerSettings
new CompilerSettings
{
AllowUnsafeBlocks = msBuildProject.AllowUnsafeBlocks,
CheckForOverflow = msBuildProject.CheckForOverflowUnderflow,
};
CompilerSettings.ConditionalSymbols.AddRange(msBuildProject.DefineConstants);
#endregion
ProjectContent = new CSharpProjectContent();
ProjectContent = ProjectContent.SetAssemblyName(msBuildProject.AssemblyName);
ProjectContent = ProjectContent.SetProjectFileName(msBuildProject.FileName.FullPath);
ProjectContent = ProjectContent.SetCompilerSettings(CompilerSettings);
Files = msBuildProject.CompiledFileNames.Select(
f => cSharpFileFactory.BuildCSharpFile(this, new FilePath(f))).ToList();
ProjectContent = ProjectContent.AddOrUpdateFiles(
Files.Select(f => f.UnresolvedTypeSystemForFile));
ProjectContent = ProjectContent.AddAssemblyReferences(msBuildProject.ReferencedAssemblies);
}