public void TestInterfaceOnClass()
        {
            var cmp = new TypeComparer();

            Assert.IsTrue(cmp.CanCompare(typeof(ITopologicalComparer), typeof(TypeComparer)));
            Assert.IsTrue(cmp.Compare(typeof(ITopologicalComparer), typeof(TypeComparer)) < 0);
        }
        public void TestRoot()
        {
            var cmp = new TypeComparer();

            Assert.IsTrue(cmp.CanCompare(typeof(object), typeof(TypeComparer)));
            Assert.IsTrue(cmp.Compare(typeof(object), typeof(TypeComparer)) < 0);
        }
Beispiel #3
0
        private int CompareSymbolAndNamedTypeSymbol(ISymbol symbol, INamedTypeSymbol typeSymbol)
        {
            int diff = TypeComparer.Compare(symbol.ContainingType, typeSymbol);

            if (diff != 0)
            {
                return(diff);
            }

            return(1);
        }
Beispiel #4
0
        private int CompareNamedTypeSymbol(INamedTypeSymbol typeSymbol1, INamedTypeSymbol typeSymbol2)
        {
            int diff = CompareContainingNamespace(typeSymbol1, typeSymbol2);

            if (diff != 0)
            {
                return(diff);
            }

            return(TypeComparer.Compare(typeSymbol1, typeSymbol2));
        }
    public ConnectionState GetReplacement(ConnectionTableState cts,
                                          Connection c, ConnectionState c1, ConnectionState c2)
    {
        int tcmp = _tc.Compare(c1.Edge.TAType, c2.Edge.TAType);

        if (tcmp < 0)
        {
            return(c1);
        }
        else if (tcmp > 0)
        {
            return(c2);
        }
        else
        {
            //We don't know how to handle, move on:
            return(_fallback.GetReplacement(cts, c, c1, c2));
        }
    }
Beispiel #6
0
        public static void CompareBuiltControllerToStaticController(Type builtControllerType, Type staticControllerType)
        {
            var comparer = new TypeComparer(new TypeComparisonFeature[]
            {
                TypeComparisonFeature.ParentType,
                TypeComparisonFeature.HandlerActionMethod,
            }, new TypeComparerOptions());

            var comparisonResult = comparer.Compare(builtControllerType, staticControllerType);

            if (!comparisonResult.CompleteMatch)
            {
                throw new Exception(string.Format(
                                        "Dynamically created controller {0} does not match statically defined controller {1}: {2}",
                                        staticControllerType.Name,
                                        builtControllerType.Name,
                                        string.Join(" ", comparisonResult.MismatchingFeaturesResults
                                                    .Select(comparedFeaturesResult => comparedFeaturesResult.Message))));
            }
        }
Beispiel #7
0
 public static bool IsCovariantTo(this Type type, Type inspected)
 {
     return(TypeComparer.Compare(type, inspected));
 }