예제 #1
0
    private static bool IsCompatibleType(
        IDocumentValidatorContext context,
        INamedType parentType,
        INamedType typeCondition)
    {
        if (parentType.IsAssignableFrom(typeCondition))
        {
            return(true);
        }

        IReadOnlyCollection <ObjectType> types1 = context.Schema.GetPossibleTypes(parentType);
        IReadOnlyCollection <ObjectType> types2 = context.Schema.GetPossibleTypes(typeCondition);

        foreach (ObjectType a in types1)
        {
            foreach (ObjectType b in types2)
            {
                if (ReferenceEquals(a, b))
                {
                    return(true);
                }
            }
        }

        return(false);
    }
예제 #2
0
 private static bool IsCompatibleType(INamedType parentType, INamedType typeCondition)
 {
     if (parentType.IsAssignableFrom(typeCondition))
     {
         return(true);
     }
     else if (parentType.Kind == TypeKind.Object &&
              typeCondition.Kind == TypeKind.Interface &&
              parentType is ObjectType o &&
              typeCondition is InterfaceType i &&
              o.IsImplementing(i))
     {
         return(true);
     }