public int CompareTo(object obj) { IArrayType type = obj as IArrayType; if (type == null) { return(-1); } return(CompareItems.CompareArrayTypes(this, type)); }
public int CompareTo(object obj) { ITypeReference reference = obj as ITypeReference; if (reference == null) { return(-1); } return(CompareItems.CompareTypeReferences(this, reference)); }
public int CompareTo(object obj) { IMethodReference imr = obj as IMethodReference; if (imr == null) { return(-1); } return(CompareItems.CompareMethodReferences(this, imr)); }
/// <summary> /// Determine if two method references are equal /// </summary> /// <param name="imr1">First method reference</param> /// <param name="imr2">Second method reference</param> /// <returns>true if equal</returns> internal static bool MethodReferencesAreEqual(IMethodReference imr1, IMethodReference imr2) { if (imr1 == imr2) { return(true); } // Method references and declaring types must be the same return(CompareItems.MethodReferencesAreEqualInner(imr1, imr2) && imr1.DeclaringType.Equals(imr2.DeclaringType)); }
public int CompareTo(object obj) { IPropertyReference reference = obj as IPropertyReference; if (reference == null) { throw new NotSupportedException(); } return(CompareItems.ComparePropertyReferences(this, reference)); }
/// <summary> /// Determine if two method references are equal, ignoring declaring type /// </summary> /// <param name="imr1">Method reference 1</param> /// <param name="imr2">Method reference 2</param> /// <returns>true if equal</returns> internal static bool MethodReferencesAreEqualInner(IMethodReference imr1, IMethodReference imr2) { // Nme and generic arguments must be the same... if (imr1.Name != imr2.Name || imr1.GenericArguments.Count != imr2.GenericArguments.Count) { return(false); } // ... and generic method defining this specialization (if it is one) IMethodReference genericRef1 = imr1.GenericMethod; IMethodReference genericRef2 = imr2.GenericMethod; if (genericRef1 == null) { if (genericRef2 != null) { return(false); } } else { if (genericRef2 == null) { return(false); } if (!genericRef1.Equals(genericRef2)) { return(false); } for (int i = 0; i < imr2.GenericArguments.Count; i++) { IType tRef1 = imr1.GenericArguments[i]; IType tRef2 = imr2.GenericArguments[i]; if (tRef1 == null || tRef2 == null || !tRef1.Equals(tRef2)) { return(false); } } } // ... and method signatures if (!CompareItems.MethodSignaturesAreEqual(imr1, imr2)) { return(false); } return(true); }
public int CompareTo(object obj) { if (this == obj) { return(0); } IMethodReference imr = obj as IMethodReference; if (imr == null) { throw new ArgumentException("Cannot compare a MethodInstanceDeclaration to a null reference"); } return(CompareItems.CompareMethodReferences(this, imr)); }
/// <summary> /// Compare one method reference to another /// </summary> /// <param name="obj">Method reference to compare to</param> /// <returns>-1, 0 or 1</returns> public int CompareTo(object obj) { if (this == obj) { return(0); } IMethodReference imr = obj as IMethodReference; if (imr == null) { throw new NotSupportedException("Cannot compare an IMethodReference to a null reference"); } return(CompareItems.CompareMethodReferences(this, imr)); }
/// <summary> /// Determines if this method reference is equal to another (representing the method declaration) /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (this == obj) { return(true); } IMethodReference that = obj as IMethodReference; if (that == null) { return(false); } return(CompareItems.MethodReferencesAreEqual(this, that)); }
public override bool Equals(object obj) { if (this == obj) { return(true); } IArrayType arrayType = obj as IArrayType; if (arrayType == null) { return(false); } return(CompareItems.ArrayTypesAreEqual(this, arrayType)); }
/// <summary> /// Resolve the method reference /// </summary> /// <returns>The declaration for the reference</returns> public IMethodDeclaration Resolve() { // If we have already resolved this, and the reference is still // alive, then return it. if (this.methodDeclaration != null && this.methodDeclaration.IsAlive) { return((IMethodDeclaration)this.methodDeclaration.Target); } // Get the declaring type reference ITypeReference declrType = this.DeclaringType as ITypeReference; // Search up the inheritance chain for the method declaration while (declrType != null) { // Resolve the declaring type ITypeDeclaration decl = declrType.Resolve(); if (decl == null) { return(null); } // Look through the declaring type's methods foreach (IMethodDeclaration imd in decl.Methods) { if (CompareItems.MethodReferencesAreEqualInner(this, imd)) { this.methodDeclaration = new WeakReference(imd); return((IMethodDeclaration)(this.methodDeclaration.Target)); } } // Go up an inheritance level declrType = decl.BaseType; } // Nothing doing return(null); }
public int CompareTo(object obj) { return(CompareItems.CompareTypeReferences(this, obj as ITypeReference)); }