예제 #1
0
 private IEnumerable <IEnumerable <Type> > AllGenericBase(Type def, IEnumerable <Type> args, Type[] tparams, Type[] targs, int pos)
 {
     if (pos >= targs.Length)
     {
         Type con;
         try{
             con = def.MakeGenericType(targs);
         }catch (ArgumentException)
         {
             yield break;
         }
         yield return(new Type[] { con });
     }
     else
     {
         foreach (Type t in args)
         {
             if (!ConstraintsOkay(tparams[pos], t))
             {
                 continue;
             }
             targs[pos] = t;
             yield return(SequenceTools.SelectManyInfinite(AllGenericBase(def, args, tparams, (Type[])targs.Clone(), pos + 1)));
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Returns all constructed generic types from a type.
 /// </summary>
 /// <param name="def">The type definition.</param>
 /// <param name="args">The possible type arguments.</param>
 public IEnumerable <Type> AllGeneric(Type def, IEnumerable <Type> args)
 {
     if (!def.IsGenericTypeDefinition)
     {
         return(Type.EmptyTypes);
     }
     Type[] tparams = def.GetGenericArguments();
     Type[] targs   = new Type[tparams.Length];
     return(SequenceTools.SelectManyInfinite(AllGenericBase(def, args, tparams, targs, 0)));
 }
예제 #3
0
 private IEnumerable <Type> AllGenericTypes(IEnumerable <Type> source)
 {
     if (Generic)
     {
         return(SequenceTools.SelectManyInfinite(source.Select(t => AllGenericItself(t, AllTypes(source)))));
     }
     else
     {
         return(source);
     }
 }
예제 #4
0
 /// <summary>
 /// Enumerates all types constructed from the input.
 /// </summary>
 /// <param name="source">The input types.</param>
 public IEnumerable <Type> AllTypes(IEnumerable <Type> source)
 {
     return(SequenceTools.SelectManyInfinite(AllGenericTypes(source).Select(t => AllDerivedRecursive(t))));
 }