本文整理汇总了C#中Microsoft.Build.Shared.AssemblyNameExtension.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyNameExtension.Equals方法的具体用法?C# AssemblyNameExtension.Equals怎么用?C# AssemblyNameExtension.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Shared.AssemblyNameExtension
的用法示例。
在下文中一共展示了AssemblyNameExtension.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: AssemblyNameExtension
bool IComReferenceResolver.ResolveComAssemblyReference(string fullAssemblyName, out string assemblyPath)
{
AssemblyNameExtension extension = new AssemblyNameExtension(fullAssemblyName);
foreach (ComReferenceWrapperInfo info in this.cachePia.Values)
{
if (info.path != null)
{
AssemblyNameExtension that = new AssemblyNameExtension(AssemblyName.GetAssemblyName(info.path));
if (extension.Equals(that))
{
assemblyPath = info.path;
return true;
}
if (extension.Equals(info.originalPiaName))
{
assemblyPath = info.path;
return true;
}
}
}
foreach (ComReferenceWrapperInfo info2 in this.cacheTlb.Values)
{
if (info2.path != null)
{
AssemblyNameExtension extension3 = new AssemblyNameExtension(AssemblyName.GetAssemblyName(info2.path));
if (extension.Equals(extension3))
{
assemblyPath = info2.path;
return true;
}
}
}
foreach (ComReferenceWrapperInfo info3 in this.cacheAx.Values)
{
if (info3.path != null)
{
AssemblyNameExtension extension4 = new AssemblyNameExtension(AssemblyName.GetAssemblyName(info3.path));
if (extension.Equals(extension4))
{
assemblyPath = info3.path;
return true;
}
}
}
assemblyPath = null;
return false;
}
示例3: FileMatchesAssemblyName
protected bool FileMatchesAssemblyName(AssemblyNameExtension assemblyName, bool isPrimaryProjectReference, bool wantSpecificVersion, bool allowMismatchBetweenFusionNameAndFileName, string pathToCandidateAssembly, ResolutionSearchLocation searchLocation)
{
searchLocation.FileNameAttempted = pathToCandidateAssembly;
if (!allowMismatchBetweenFusionNameAndFileName)
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(pathToCandidateAssembly);
if (string.Compare(assemblyName.Name, fileNameWithoutExtension, StringComparison.CurrentCultureIgnoreCase) != 0)
{
if (searchLocation != null)
{
if (fileNameWithoutExtension.Length > 0)
{
searchLocation.AssemblyName = new AssemblyNameExtension(fileNameWithoutExtension);
searchLocation.Reason = NoMatchReason.FusionNamesDidNotMatch;
}
else
{
searchLocation.Reason = NoMatchReason.TargetHadNoFusionName;
}
}
return false;
}
}
bool flag = (assemblyName != null) && assemblyName.IsSimpleName;
if (this.fileExists(pathToCandidateAssembly))
{
if (!this.compareProcessorArchitecture)
{
if (((assemblyName == null) && isPrimaryProjectReference) && !wantSpecificVersion)
{
return true;
}
if ((isPrimaryProjectReference && !wantSpecificVersion) && flag)
{
return true;
}
}
AssemblyNameExtension that = null;
try
{
that = this.getAssemblyName(pathToCandidateAssembly);
}
catch (FileLoadException)
{
}
if (searchLocation != null)
{
searchLocation.AssemblyName = that;
}
if (that != null)
{
if (((this.compareProcessorArchitecture && (that.AssemblyName.ProcessorArchitecture != this.targetProcessorArchitecture)) && ((this.targetProcessorArchitecture != ProcessorArchitecture.None) && (that.AssemblyName.ProcessorArchitecture != ProcessorArchitecture.None))) && ((this.targetProcessorArchitecture != ProcessorArchitecture.MSIL) && (that.AssemblyName.ProcessorArchitecture != ProcessorArchitecture.MSIL)))
{
searchLocation.Reason = NoMatchReason.ProcessorArchitectureDoesNotMatch;
return false;
}
bool flag2 = (wantSpecificVersion && (assemblyName != null)) && assemblyName.Equals(that);
bool flag3 = (!wantSpecificVersion && (assemblyName != null)) && assemblyName.PartialNameCompare(that);
if (flag2 || flag3)
{
return true;
}
if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.FusionNamesDidNotMatch;
}
}
else if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.TargetHadNoFusionName;
}
}
else if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.FileNotFound;
}
return false;
}
示例4: 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;
}
示例5: GetPathForAssemblyInGac
/// <summary>
/// Checks to see if the assemblyName passed in is in the GAC.
/// </summary>
private static string GetPathForAssemblyInGac(AssemblyNameExtension assemblyName, ProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, FileExists fileExists, bool fullFusionName, bool specificVersion)
{
if (assemblyName.Equals(new AssemblyNameExtension("V, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
{
return null;
}
else if (assemblyName.Equals(new AssemblyNameExtension("W, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
{
return @"C:\MyComponents2\W.dll";
}
else if (assemblyName.Equals(new AssemblyNameExtension("Z, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
{
return null;
}
else if (assemblyName.Equals(new AssemblyNameExtension("X, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
{
return @"C:\MyComponents\X.dll";
}
else if (assemblyName.Equals(new AssemblyNameExtension("Y, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
{
return null;
}
else
{
string gacLocation = null;
if (assemblyName.Version != null)
{
gacLocation = GlobalAssemblyCache.GetLocation(assemblyName, targetProcessorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fullFusionName, fileExists, null, null, specificVersion /* this value does not matter if we are passing a full fusion name*/);
}
return gacLocation;
}
}
示例6: AssemblyNameExtension
//.........这里部分代码省略.........
return false;
}
}
bool isSimpleAssemblyName = assemblyName == null ? false : assemblyName.IsSimpleName;
if (fileExists(pathToCandidateAssembly))
{
// If the resolver we are using is targeting a given processor architecture then we must crack open the assembly and make sure the architecture is compatible
// We cannot do these simple name matches.
if (!compareProcessorArchitecture)
{
// If the file existed and the reference is a simple primary reference which does not contain an assembly name (say a raw file name)
// then consider this a match.
if (assemblyName == null && isPrimaryProjectReference && !wantSpecificVersion)
{
return true;
}
if (isPrimaryProjectReference && !wantSpecificVersion && isSimpleAssemblyName)
{
return true;
}
}
// We have strong name information, so do some added verification here.
AssemblyNameExtension targetAssemblyName = null;
try
{
targetAssemblyName = getAssemblyName(pathToCandidateAssembly);
}
catch (System.IO.FileLoadException)
{
// Its pretty hard to get here, you need an assembly that contains a valid reference
// to a dependent assembly that, in turn, throws a FileLoadException during GetAssemblyName.
// Still it happened once, with an older version of the CLR.
// ...falling through and relying on the targetAssemblyName==null behavior below...
}
if (searchLocation != null)
{
searchLocation.AssemblyName = targetAssemblyName;
}
// targetAssemblyName may be null if there was no metadata for this assembly.
// In this case, there's no match.
if (targetAssemblyName != null)
{
// If we are targeting a given processor architecture check to see if they match, if we are targeting MSIL then any architecture will do.
if (compareProcessorArchitecture)
{
// Only reject the assembly if the target processor architecture does not match the assemby processor architecture and the assembly processor architecture is not NONE or MSIL.
if (
targetAssemblyName.AssemblyName.ProcessorArchitecture != targetProcessorArchitecture && /* The target and assembly architectures do not match*/
(targetProcessorArchitecture != ProcessorArchitecture.None && targetAssemblyName.AssemblyName.ProcessorArchitecture != ProcessorArchitecture.None) /*The assembly is not none*/
&& (targetProcessorArchitecture != ProcessorArchitecture.MSIL && targetAssemblyName.AssemblyName.ProcessorArchitecture != ProcessorArchitecture.MSIL) /*The assembly is not MSIL*/
)
{
searchLocation.Reason = NoMatchReason.ProcessorArchitectureDoesNotMatch;
return false;
}
}
bool matchedSpecificVersion = (wantSpecificVersion && assemblyName != null && assemblyName.Equals(targetAssemblyName));
bool matchPartialName = !wantSpecificVersion && assemblyName != null && assemblyName.PartialNameCompare(targetAssemblyName);
if (matchedSpecificVersion || matchPartialName)
{
return true;
}
else
{
// Reason was: FusionNames did not match.
if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.FusionNamesDidNotMatch;
}
}
}
else
{
// Reason was: Target had no fusion name.
if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.TargetHadNoFusionName;
}
}
}
else
{
// Reason was: No file found at that location.
if (searchLocation != null)
{
searchLocation.Reason = NoMatchReason.FileNotFound;
}
}
return false;
}
示例7: ResolveAssembly
/// <summary>
/// This is an assembly resolution handler necessary for fixing up types instantiated in different
/// AppDomains and loaded with a Assembly.LoadFrom equivalent call. See comments in TaskEngine.ExecuteTask
/// for more details.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
/// <returns></returns>
internal Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
// Is this our task assembly?
if (_taskAssemblyFile != null)
{
if (File.Exists(_taskAssemblyFile))
{
try
{
AssemblyNameExtension taskAssemblyName = new AssemblyNameExtension(AssemblyName.GetAssemblyName(_taskAssemblyFile));
AssemblyNameExtension argAssemblyName = new AssemblyNameExtension(args.Name);
if (taskAssemblyName.Equals(argAssemblyName))
{
#if (!CLR2COMPATIBILITY)
return Assembly.UnsafeLoadFrom(_taskAssemblyFile);
#else
return Assembly.LoadFrom(taskAssemblyFile);
#endif
}
}
// any problems with the task assembly? return null.
catch (FileNotFoundException)
{
return null;
}
catch (BadImageFormatException)
{
return null;
}
}
}
// otherwise, have a nice day.
return null;
}
示例8: AssemblyNameExtension
/*
* Method: ResolveComAssemblyReference
*
* Resolves a COM wrapper assembly reference based on the COM references resolved so far. This method is necessary
* for Ax wrappers only, so all necessary references will be resolved by then (since we resolve them in
* the following order: pia, tlbimp, aximp)
*
* This is the method available for references to call back to resolve their dependencies
*/
bool IComReferenceResolver.ResolveComAssemblyReference(string fullAssemblyName, out string assemblyPath)
{
AssemblyNameExtension fullAssemblyNameEx = new AssemblyNameExtension(fullAssemblyName);
foreach (ComReferenceWrapperInfo wrapperInfo in _cachePia.Values)
{
// this should not happen, but it would be a non fatal error
Debug.Assert(wrapperInfo.path != null);
if (wrapperInfo.path == null)
continue;
// we have already verified all cached wrappers, so we don't expect this methods to throw anything
AssemblyNameExtension wrapperAssemblyNameEx = new AssemblyNameExtension(AssemblyName.GetAssemblyName(wrapperInfo.path));
if (fullAssemblyNameEx.Equals(wrapperAssemblyNameEx))
{
assemblyPath = wrapperInfo.path;
return true;
}
// The PIA might have been redirected, so check its original assembly name too
else if (fullAssemblyNameEx.Equals(wrapperInfo.originalPiaName))
{
assemblyPath = wrapperInfo.path;
return true;
}
}
foreach (ComReferenceWrapperInfo wrapperInfo in _cacheTlb.Values)
{
// temporary wrapper? skip it.
if (wrapperInfo.path == null)
continue;
// we have already verified all cached wrappers, so we don't expect this methods to throw anything
AssemblyNameExtension wrapperAssemblyNameEx = new AssemblyNameExtension(AssemblyName.GetAssemblyName(wrapperInfo.path));
if (fullAssemblyNameEx.Equals(wrapperAssemblyNameEx))
{
assemblyPath = wrapperInfo.path;
return true;
}
}
foreach (ComReferenceWrapperInfo wrapperInfo in _cacheAx.Values)
{
// this should not happen, but it would be a non fatal error
Debug.Assert(wrapperInfo.path != null);
if (wrapperInfo.path == null)
continue;
// we have already verified all cached wrappers, so we don't expect this methods to throw anything
AssemblyNameExtension wrapperAssemblyNameEx = new AssemblyNameExtension(AssemblyName.GetAssemblyName(wrapperInfo.path));
if (fullAssemblyNameEx.Equals(wrapperAssemblyNameEx))
{
assemblyPath = wrapperInfo.path;
return true;
}
}
assemblyPath = null;
return false;
}