Beispiel #1
0
 public override bool IsMatch(ResolutionContext context)
 {
     // destination type must be IEnumerable interface or a class implementing at least IList
     return(PrimitiveExtensions.IsEnumerableType(context.SourceType) &&
            (PrimitiveExtensions.IsListType(context.DestinationType) ||
             DestinationIListTypedAsIEnumerable(context)));
 }
Beispiel #2
0
        public bool IsMatch(ResolutionContext context)
        {
            var isMatch = PrimitiveExtensions.IsEnumerableType(context.SourceType) &&
                          PrimitiveExtensions.IsCollectionType(context.DestinationType);

            return(isMatch);
        }
Beispiel #3
0
        public bool IsMatch(ResolutionContext context)
        {
            if (
                !(PrimitiveExtensions.IsEnumerableType(context.SourceType) &&
                  TypeExtensions.IsGenericType(context.DestinationType)))
            {
                return(false);
            }

            var genericType = context.DestinationType.GetGenericTypeDefinition();

            return(genericType == typeof(ReadOnlyCollection <>));
        }
Beispiel #4
0
 public override bool IsMatch(ResolutionContext context)
 {
     return((context.DestinationType.IsArray) && (PrimitiveExtensions.IsEnumerableType(context.SourceType)));
 }
Beispiel #5
0
 public bool IsMatch(ResolutionContext context)
 {
     return((PrimitiveExtensions.IsDictionaryType(context.DestinationType)) &&
            (PrimitiveExtensions.IsEnumerableType(context.SourceType)) &&
            (!PrimitiveExtensions.IsDictionaryType(context.SourceType)));
 }
Beispiel #6
0
 private static bool DestinationIListTypedAsIEnumerable(ResolutionContext context)
 {
     return(TypeExtensions.IsInterface(context.DestinationType) &&
            PrimitiveExtensions.IsEnumerableType(context.DestinationType) &&
            (context.DestinationValue == null || context.DestinationValue is IList));
 }
Beispiel #7
0
 public override bool IsMatch(ResolutionContext context)
 {
     return(context.DestinationType.IsArray && context.DestinationType.GetArrayRank() > 1 &&
            PrimitiveExtensions.IsEnumerableType(context.SourceType));
 }
Beispiel #8
0
 private static bool IsProjection <T>(Type resultType)
 {
     return(PrimitiveExtensions.IsEnumerableType(resultType) && !PrimitiveExtensions.IsQueryableType(resultType) &&
            resultType != typeof(string) && PrimitiveExtensions.GetGenericElementType(resultType) == typeof(T));
 }