Exemplo n.º 1
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);
        }
        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);
        }
 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);
     }
 }
Exemplo n.º 4
0
 public void IsTupleType_is_false_for_non_tuples(Type type)
 {
     Assert.False(HarshTuple.IsTupleType(type));
 }
Exemplo n.º 5
0
 public void IsTupleType_is_true_for_tuples(Type type)
 {
     Assert.True(HarshTuple.IsTupleType(type));
 }