Exemple #1
0
 /// <summary>
 /// Returns true if the two signatures match according to the criteria of the CLR loader.
 /// </summary>
 public static bool SignaturesAreEqual(ISignature signature1, ISignature signature2)
 {
     if (signature1.CallingConvention != signature2.CallingConvention)
     {
         return(false);
     }
     if (signature1.ReturnValueIsByRef != signature2.ReturnValueIsByRef)
     {
         return(false);
     }
     if (signature1.ReturnValueIsModified != signature2.ReturnValueIsModified)
     {
         return(false);
     }
     if (!TypeHelper.TypesAreEquivalent(signature1.Type, signature2.Type))
     {
         return(false);
     }
     return(IteratorHelper.EnumerablesAreEqual(signature1.Parameters, signature2.Parameters, ParameterInformationComparer));
 }
Exemple #2
0
        /// <summary>
        /// Returns true if the given object is an identifier that identifies the same object as this identifier.
        /// </summary>
        //^ [Confined]
        public sealed override bool Equals(object /*?*/ obj)
        {
            if (obj == (object)this)
            {
                return(true);
            }
            AssemblyIdentity /*?*/ otherAssembly = obj as AssemblyIdentity;

            if (otherAssembly == null)
            {
                return(false);
            }
            if (this.Name.UniqueKeyIgnoringCase != otherAssembly.Name.UniqueKeyIgnoringCase)
            {
                return(false);
            }
            if (this.Version != otherAssembly.Version)
            {
                return(false);
            }
            if (string.Compare(this.Culture, otherAssembly.Culture, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }
            if (IteratorHelper.EnumerableIsNotEmpty(this.PublicKeyToken))
            {
                return(IteratorHelper.EnumerablesAreEqual(this.PublicKeyToken, otherAssembly.PublicKeyToken));
            }
            else
            {
                if (this.Location.Length == 0 || otherAssembly.Location.Length == 0)
                {
                    return(true);
                }
                return(string.Compare(this.Location, otherAssembly.Location, StringComparison.OrdinalIgnoreCase) == 0);
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns true if the given two assembly references are to be considered equivalent.
 /// </summary>
 public static bool AssembliesAreEquivalent(IAssemblyReference /*?*/ assembly1, IAssemblyReference /*?*/ assembly2)
 {
     if (assembly1 == null || assembly2 == null)
     {
         return(false);
     }
     if (assembly1 == assembly2)
     {
         return(true);
     }
     if (assembly1.Name.UniqueKeyIgnoringCase != assembly2.Name.UniqueKeyIgnoringCase)
     {
         return(false);
     }
     if (!assembly1.Version.Equals(assembly2.Version))
     {
         return(false);
     }
     if (!assembly1.Culture.Equals(assembly2.Culture))
     {
         return(false);
     }
     return(IteratorHelper.EnumerablesAreEqual <byte>(assembly1.PublicKeyToken, assembly2.PublicKeyToken));
 }
Exemple #4
0
        /// <summary>
        /// Returns true if the given object is an identifier that identifies the same object as this identifier.
        /// </summary>
        //^ [Confined]
        public sealed override bool Equals(object /*?*/ obj)
        {
            if (obj == (object)this)
            {
                return(true);
            }
            AssemblyIdentity /*?*/ otherAssembly = obj as AssemblyIdentity;

            if (otherAssembly == null)
            {
                return(false);
            }
            if (this.Name.UniqueKeyIgnoringCase != otherAssembly.Name.UniqueKeyIgnoringCase)
            {
                return(false);
            }
            if (this.Version != otherAssembly.Version)
            {
                return(false);
            }
            if (string.Compare(this.Culture, otherAssembly.Culture, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }
            if (IteratorHelper.EnumerableIsNotEmpty(this.PublicKeyToken))
            {
                return(IteratorHelper.EnumerablesAreEqual(this.PublicKeyToken, otherAssembly.PublicKeyToken));
            }
            else
            {
                // This can be dangerous! Returning true here means that weakly named assemblies are assumed to be the
                // same just because their name is the same. So two assemblies from different locations but the same name
                // should *NOT* be allowed.
                return(true);
            }
        }