Esempio n. 1
0
 /// <summary>
 /// Gets the eligible extension methods.
 /// </summary>
 /// <param name="substituteInferredTypes">
 /// Specifies whether to produce a <see cref="SpecializedMethod"/>
 /// when type arguments could be inferred from <see cref="TargetType"/>.
 /// This setting is only used for inferred types and has no effect if the type parameters are
 /// specified explicitly.
 /// </param>
 /// <remarks>
 /// The results are stored in nested lists because they are grouped by using scope.
 /// That is, for "using SomeExtensions; namespace X { using MoreExtensions; ... }",
 /// the return value will be
 /// new List {
 ///    new List { all extensions from MoreExtensions },
 ///    new List { all extensions from SomeExtensions }
 /// }
 /// </remarks>
 public IEnumerable<IEnumerable<IMethod>> GetEligibleExtensionMethods(bool substituteInferredTypes)
 {
     var result = new List<List<IMethod>>();
     foreach (var methodGroup in GetExtensionMethods())
     {
         var outputGroup = new List<IMethod>();
         foreach (var method in methodGroup)
         {
             IType[] inferredTypes;
             if (ResolveContext.IsEligibleExtensionMethod(this.TargetType, method, true, out inferredTypes))
             {
                 if (substituteInferredTypes && inferredTypes != null)
                 {
                     outputGroup.Add(method.Specialize(new TypeParameterSubstitution(null, inferredTypes)));
                 }
                 else
                 {
                     outputGroup.Add(method);
                 }
             }
         }
         if (outputGroup.Count > 0)
             result.Add(outputGroup);
     }
     return result;
 }