本文整理汇总了C#中AssemblyIdentity.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyIdentity.Equals方法的具体用法?C# AssemblyIdentity.Equals怎么用?C# AssemblyIdentity.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyIdentity
的用法示例。
在下文中一共展示了AssemblyIdentity.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equality
public void Equality()
{
var id1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
var id2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray<byte>), hasPublicKey: false, isRetargetable: false);
var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false);
var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true);
var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
Assert.True(id1.Equals(id1));
Assert.True(id1.Equals(id2));
Assert.True(id2.Equals(id1));
Assert.True(id1.Equals(id11));
Assert.True(id11.Equals(id1));
Assert.True(id2.Equals(id22));
Assert.True(id22.Equals(id2));
Assert.False(id1.Equals(id3));
Assert.False(id1.Equals(id4));
Assert.False(id1.Equals(id5));
Assert.False(id1.Equals(id6));
Assert.False(id1.Equals(id7));
Assert.False(id1.Equals(id8));
Assert.Equal((object)id1, id1);
Assert.NotNull(id1);
Assert.False(id2.Equals((AssemblyIdentity)null));
Assert.Equal(id1.GetHashCode(), id2.GetHashCode());
Assert.False(win1.Equals(win2));
Assert.False(win1.Equals(id1));
Assert.True(win1.Equals(win3));
Assert.Equal(win1.GetHashCode(), win3.GetHashCode());
}
示例2: Equality_InvariantCulture
public void Equality_InvariantCulture()
{
var neutral1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "NEUtral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var neutral2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), null, RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var neutral3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "neutral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
var invariant = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
Assert.True(neutral1.Equals(invariant));
Assert.True(neutral2.Equals(invariant));
Assert.True(neutral3.Equals(invariant));
}
示例3: CreateAsync
public static async Task<CodeAction> CreateAsync(Project project, AssemblyIdentity missingAssemblyIdentity, CancellationToken cancellationToken)
{
var dependencyGraph = project.Solution.GetProjectDependencyGraph();
// We want to find a project that generates this assembly, if one so exists. We therefore
// search all projects that our project with an error depends on. We want to do this for
// complicated and evil scenarios like this one:
//
// C -> B -> A
//
// A'
//
// Where, for some insane reason, A and A' are two projects that both emit an assembly
// by the same name. So imagine we are using a type in B from C, and we are missing a
// reference to A.dll. Both A and A' are candidates, but we know we can throw out A'
// since whatever type from B we are using that's causing the error, we know that type
// isn't referencing A'. Put another way: this code action adds a reference, but should
// never change the transitive closure of project references that C has.
//
// Doing this filtering also means we get to check less projects (good), and ensures that
// whatever project reference we end up adding won't add a circularity (also good.)
foreach (var candidateProjectId in dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(project.Id))
{
var candidateProject = project.Solution.GetProject(candidateProjectId);
if (string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
{
// The name matches, so let's see if the full identities are equal.
var compilation = await candidateProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
if (missingAssemblyIdentity.Equals(compilation.Assembly.Identity))
{
// It matches, so just add a reference to this
return new AddMissingReferenceCodeAction(project,
string.Format(FeaturesResources.Add_project_reference_to_0, candidateProject.Name),
new ProjectReference(candidateProjectId), missingAssemblyIdentity);
}
}
}
// No matching project, so metadata reference
var description = string.Format(FeaturesResources.Add_reference_to_0, missingAssemblyIdentity.GetDisplayName());
return new AddMissingReferenceCodeAction(project, description, null, missingAssemblyIdentity);
}
示例4: TryGetAssemblyLoadedFromPath
private Assembly TryGetAssemblyLoadedFromPath(AssemblyIdentity identity, string directory)
{
string pathWithoutExtension = Path.Combine(directory, identity.Name);
foreach (var extension in RuntimeMetadataReferenceResolver.AssemblyExtensions)
{
AssemblyAndLocation assemblyAndLocation;
if (_assembliesLoadedFromLocationByFullPath.TryGetValue(pathWithoutExtension + extension, out assemblyAndLocation) &&
identity.Equals(AssemblyIdentity.FromAssemblyDefinition(assemblyAndLocation.Assembly)))
{
return assemblyAndLocation.Assembly;
}
}
return null;
}