本文整理汇总了C#中Microsoft.Build.Shared.AssemblyNameExtension.CompareBaseNameTo方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyNameExtension.CompareBaseNameTo方法的具体用法?C# AssemblyNameExtension.CompareBaseNameTo怎么用?C# AssemblyNameExtension.CompareBaseNameTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Shared.AssemblyNameExtension
的用法示例。
在下文中一共展示了AssemblyNameExtension.CompareBaseNameTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
/// <summary>
/// Get unification information for the given assembly name.
/// </summary>
/// <param name="assemblyName">The assembly name.</param>
/// <param name="unifiedVersion">The new version of the assembly to use.</param>
/// <param name="unificationReason">The reason this reference was unified.</param>
/// <param name="isPrerequisite">True if this is a prereq assembly.</param>
/// <returns>True if there was a unification.</returns>
private bool UnifyAssemblyNameVersions
(
AssemblyNameExtension assemblyName,
out Version unifiedVersion,
out UnificationReason unificationReason,
out bool isPrerequisite,
out bool? isRedistRoot,
out string redistName
)
{
unifiedVersion = assemblyName.Version;
isPrerequisite = false;
isRedistRoot = null;
redistName = null;
unificationReason = UnificationReason.DidntUnify;
// If there's no version, for example in a simple name, then no remapping is possible.
if (assemblyName.Version == null)
{
return false;
}
// Try for a remapped assemblies unification.
if (_remappedAssemblies != null)
{
foreach (DependentAssembly remappedAssembly in _remappedAssemblies)
{
// First, exclude anything without the simple name match
AssemblyNameExtension comparisonAssembly = new AssemblyNameExtension((AssemblyName)remappedAssembly.PartialAssemblyName.Clone());
if (assemblyName.CompareBaseNameTo(comparisonAssembly) == 0)
{
// Comparison assembly is a partial name. Give it our version.
comparisonAssembly.ReplaceVersion(assemblyName.Version);
if (assemblyName.Equals(comparisonAssembly))
{
foreach (BindingRedirect bindingRedirect in remappedAssembly.BindingRedirects)
{
if (assemblyName.Version >= bindingRedirect.OldVersionLow && assemblyName.Version <= bindingRedirect.OldVersionHigh)
{
// If the new version is different than the old version, then there is a unification.
if (assemblyName.Version != bindingRedirect.NewVersion)
{
unifiedVersion = bindingRedirect.NewVersion;
unificationReason = UnificationReason.BecauseOfBindingRedirect;
return true;
}
}
}
}
}
}
}
// Try for an installed assemblies unification.
if (_installedAssemblies != null)
{
_installedAssemblies.GetInfo
(
assemblyName,
out unifiedVersion,
out isPrerequisite,
out isRedistRoot,
out redistName
);
// Was there a unification?
if (unifiedVersion != assemblyName.Version)
{
unificationReason = UnificationReason.FrameworkRetarget;
return assemblyName.Version != unifiedVersion;
}
}
return false;
}
示例2: UnifyAssemblyNameVersions
private bool UnifyAssemblyNameVersions(AssemblyNameExtension assemblyName, out Version unifiedVersion, out UnificationReason unificationReason, out bool isPrerequisite, out bool? isRedistRoot, out string redistName)
{
unifiedVersion = assemblyName.Version;
isPrerequisite = false;
isRedistRoot = 0;
redistName = null;
unificationReason = UnificationReason.DidntUnify;
if (assemblyName.Version != null)
{
if (this.remappedAssemblies != null)
{
foreach (DependentAssembly assembly in this.remappedAssemblies)
{
AssemblyNameExtension that = new AssemblyNameExtension((AssemblyName) assembly.PartialAssemblyName.Clone());
if (assemblyName.CompareBaseNameTo(that) == 0)
{
that.ReplaceVersion(assemblyName.Version);
if (assemblyName.Equals(that))
{
foreach (BindingRedirect redirect in assembly.BindingRedirects)
{
if (((assemblyName.Version >= redirect.OldVersionLow) && (assemblyName.Version <= redirect.OldVersionHigh)) && (assemblyName.Version != redirect.NewVersion))
{
unifiedVersion = redirect.NewVersion;
unificationReason = UnificationReason.BecauseOfBindingRedirect;
return true;
}
}
}
}
}
}
if (this.installedAssemblies != null)
{
this.installedAssemblies.GetInfo(assemblyName, out unifiedVersion, out isPrerequisite, out isRedistRoot, out redistName);
if (unifiedVersion != assemblyName.Version)
{
unificationReason = UnificationReason.FrameworkRetarget;
return (assemblyName.Version != unifiedVersion);
}
}
}
return false;
}