public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } if (!(obj is CategoryType)) { return(false); } CategoryType other = (CategoryType)obj; return(this.GetTypeName().Equals(other.GetTypeName())); }
public IType inferCommonCategoryType(Context context, CategoryType type1, CategoryType type2, bool trySwap) { CategoryDeclaration decl1 = context.getRegisteredDeclaration <CategoryDeclaration>(type1.GetTypeName()); if (decl1.getDerivedFrom() != null) { foreach (String name in decl1.getDerivedFrom()) { CategoryType parentType = new CategoryType(name); if (parentType.isAssignableFrom(context, type2)) { return(parentType); } } // climb up the tree foreach (String name in decl1.getDerivedFrom()) { CategoryType parentType = new CategoryType(name); IType commonType = inferCommonBaseType(context, parentType, type2); if (commonType != null) { return(commonType); } } } if (trySwap) { return(inferCommonCategoryType(context, type2, type1, false)); } else { return(null); } }