//static void Main()
 //{
 //    Console.WriteLine( AssemblyInfoWriter.ListExtensions( Assembly.GetAssembly( typeof(Flags) ) ) );
 //}
 public static string ListExtensions( Assembly assembly )
 {
     var sb = new StringBuilder();
     sb.AppendFormat( "=== Extension methods (all):{0}", Environment.NewLine );
     IList<Type> types = assembly.Types( Flags.PartialNameMatch, "Extensions" );
     types.ForEach( t => Write( sb, t, t.Methods( Flags.Static | Flags.Public ).OrderBy( m => m.Name ).ToList() ) );
     return sb.ToString();
 }
 public static string ListExtensionMethodsWithSuperfluousOverloads( Assembly assembly )
 {
     var sb = new StringBuilder();
     sb.AppendFormat( "=== Extension methods that are superfluous:{0}", Environment.NewLine );
     IList<Type> types = assembly.Types( Flags.PartialNameMatch, "Extensions" );
     types.ForEach( t => Write( sb, t, t.Methods( Flags.Static | Flags.Public )
                                       	.OrderBy( m => m.Name )
                                       	.Where( m => IsSuperfluous( m, t.Methods( Flags.Static | Flags.Public, m.Name ) ) )
                                       	.ToList() ) );
     return sb.ToString();
 }
 public static string ListExtensionMethodsWhereParametersViolateConventions( Assembly assembly )
 {
     var sb = new StringBuilder();
     sb.AppendFormat( "=== Extension methods with naming violations:{0}", Environment.NewLine );
     IList<Type> types = assembly.Types( Flags.PartialNameMatch, "Extensions" );
     types.ForEach( t => Write( sb, t, t.Methods( Flags.Static | Flags.Public )
                                       	.OrderBy( m => m.Name )
                                       	.Where(
                                       		m => IsParameterViolation( typeof(Flags), "bindingFlags", true, m.Parameters() ) )
                                       	.ToList() ) );
     return sb.ToString();
 }
 /// <summary>
 /// Scans the assembly for mapping modules and creates them
 /// </summary>
 /// <param name="ModuleAssembly"></param>
 public void Setup(Assembly ModuleAssembly)
 {
     IEnumerable<Type> Modules = ModuleAssembly.Types(typeof(IModule));
     List<IModule> TempModules = new List<IModule>();
     foreach (Type Module in Modules)
     {
         if (!Module.IsInterface && !Module.IsAbstract)
             TempModules.Add((IModule)Module.Assembly.CreateInstance(Module.FullName));
     }
     foreach (IModule Module in TempModules)
     {
         Module.Manager = this;
         Module.Setup();
     }
     this.Modules.Add(TempModules);
 }
Exemple #5
0
 /// <summary>
 /// Returns a <see cref="TypeSelector"/> for selecting the types that are visible outside the
 /// specified <paramref name="assembly"/>.
 /// </summary>
 /// <param name="assembly">The assembly from which to select the types.</param>
 public static TypeSelector From(Assembly assembly)
 {
     return assembly.Types();
 }
 /// <summary>
 /// Sets up the mappings
 /// </summary>
 /// <param name="AssemblyUsing">Assembly using</param>
 private void Setup(Assembly AssemblyUsing)
 {
     if (Mappings == null)
         Mappings = new ListMapping<Type, IMapping>();
     IEnumerable<Type> Types = AssemblyUsing.Types(typeof(IMapping));
     foreach (Type Type in Types)
     {
         Type BaseType = Type.BaseType;
         IMapping TempObject = (IMapping)AssemblyUsing.CreateInstance(Type.FullName);
         TempObject.Manager = this;
         Mappings.Add(BaseType.GetGenericArguments()[0], TempObject);
     }
 }