コード例 #1
0
        public ResolveResultConverterStrategyGrouping(Type resultType)
            : base(resultType)
        {
            if (resultType == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(resultType));
            }

            if (!HarshGrouping.IsGroupingType(resultType))
            {
                throw Logger.Fatal.ArgumentFormat(
                          nameof(resultType),
                          SR.ResolveResultConverterStrategyGrouping_NotAGrouping,
                          resultType
                          );
            }

            var keyType     = resultType.GenericTypeArguments[0];
            var elementType = resultType.GenericTypeArguments[1];

            _groupingFactory = new HarshGroupingDynamicFactory(keyType, elementType);

            _keyStrategy     = GetStrategyForType(keyType);
            _elementStrategy = GetStrategyForType(elementType);
        }
コード例 #2
0
        private ResolveResultConverterStrategy GetNestedTupleStrategy(Type t)
        {
            if (HarshGrouping.IsGroupingType(t))
            {
                throw Logger.Fatal.ArgumentFormat(
                          nameof(t),
                          SR.ResolveResultConverterStrategyTuple_NestedGroupingNotAllowed,
                          ResultType
                          );
            }

            if (HarshTuple.IsTupleType(t))
            {
                return(new ResolveResultConverterStrategyTuple(t));
            }

            return(ResolveResultConverterStrategyUnpack.Instance);
        }
コード例 #3
0
        internal static ResolveResultConverterStrategy GetStrategyForType(Type type)
        {
            if (type == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(type));
            }

            if (HarshGrouping.IsGroupingType(type))
            {
                return(new ResolveResultConverterStrategyGrouping(type));
            }

            if (HarshTuple.IsTupleType(type))
            {
                return(new ResolveResultConverterStrategyTuple(type));
            }

            return(ResolveResultConverterStrategyUnpack.Instance);
        }
コード例 #4
0
 private static void AddComponentsFlat(ImmutableArray <Type> .Builder result, Type t)
 {
     if (HarshTuple.IsTupleType(t))
     {
         foreach (var ct in HarshTuple.GetComponentTypes(t))
         {
             AddComponentsFlat(result, ct);
         }
     }
     else if (HarshGrouping.IsGroupingType(t))
     {
         AddComponentsFlat(result, t.GenericTypeArguments[0]);
         AddComponentsFlat(result, t.GenericTypeArguments[1]);
     }
     else
     {
         result.Add(t);
     }
 }