private List <Type> GetAllTypes() { var types = _assemblyFinder .GetAllAssemblies() .SelectMany(x => x.GetTypes()); return(types.ToList()); }
private List <Type> CreateTypeList() { var allTypes = new List <Type>(); var assemblies = _assemblyFinder.GetAllAssemblies().Distinct(); foreach (var assembly in assemblies) { try { Type[] typesInThisAssembly; try { typesInThisAssembly = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { typesInThisAssembly = ex.Types; } if (typesInThisAssembly.IsNullOrEmpty()) { continue; } allTypes.AddRange(typesInThisAssembly.Where(type => type != null)); } catch (Exception ex) { } } return(allTypes); }
/// <summary> /// Configure the dependency injection services /// </summary> private IServiceProvider CreateServices(string connectionString) { return(new ServiceCollection() // Add common FluentMigrator services .AddFluentMigratorCore() .ConfigureRunner(rb => { rb.WithGlobalCommandTimeout(TimeSpan.FromMinutes(30)); rb.AddSqlServer2012() // Set the connection string .WithGlobalConnectionString(connectionString); var assemblies = _assemblyFinder.GetAllAssemblies(); foreach (var assembly in assemblies) { // Define the assembly containing the migrations rb.ScanIn(assembly).For.Migrations(); } } ) // Enable logging to console in the FluentMigrator way .AddLogging(lb => lb.AddFluentMigratorConsole()) // Build the service provider .BuildServiceProvider(false)); }
private List <Type> CreateTypeList() { var allTypes = new List <Type>(); var assemblies = _assemblyFinder.GetAllAssemblies().Distinct(); foreach (var assembly in assemblies) { try { Type[] typesInThisAssembly; try { typesInThisAssembly = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { typesInThisAssembly = ex.Types; } if (typesInThisAssembly == null || typesInThisAssembly.Length == 0) { continue; } allTypes.AddRange(typesInThisAssembly.Where(type => type != null)); } catch (Exception ex) { //Logger.Warn(ex.ToString(), ex); } } return(allTypes); }
public async Task Process() { var assemblies = _assembleFinder.GetAllAssemblies() .Distinct(new AssemblyFullNameComparer()) .Where(a => !a.IsDynamic && a.GetTypes().Any(t => MappingHelper.IsEntity(t)) ) .ToList(); foreach (var assembly in assemblies) { await ProcessAssemblyAsync(assembly); } }
public override IEnumerable <SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context) { var settings = new List <SettingDefinition>(); foreach (Assembly assembly in _assemblyFinder.GetAllAssemblies()) { var types = assembly .GetTypes() .Where(t => t.IsClass && typeof(ISettings).IsAssignableFrom(t)); foreach (var type in types) { var scopes = SettingScopes.All; foreach (var p in type.GetProperties()) { var key = AutoSettingsUtils.CreateSettingName(type, p.Name); var isVisibleToClients = false; var defaultValue = AutoSettingsUtils.GetDefaultValue(p.PropertyType); var attr = p.GetCustomAttribute <AutoSettingDefinitionAttribute>(); if (attr != null) { scopes = attr.Scopes; defaultValue = attr.DefaultValue; isVisibleToClients = attr.IsVisibleToClients; } settings.Add(new SettingDefinition( name: key, defaultValue: defaultValue?.ToString(), scopes: scopes, isVisibleToClients: isVisibleToClients )); } } } //int io= types.Count(); return(settings); }
private List <Type> GetAllTypes() { var allTypes = new List <Type>(); foreach (var assembly in AssemblyFinder.GetAllAssemblies().Distinct()) { try { Type[] typesInThisAssembly; try { typesInThisAssembly = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { typesInThisAssembly = ex.Types; } if (typesInThisAssembly == null || typesInThisAssembly.Count() < 0) { continue; } if (Match(assembly.GetName())) { allTypes.AddRange(typesInThisAssembly.Where(type => type != null)); } } catch (Exception ex) { Logger.Warn(ex.ToString(), ex); //throw new Exception(ex.Message); } } return(allTypes); }
public override void PreInitialize() { IocManager.Register <IShaNHibernateModuleConfiguration, ShaNHibernateModuleConfiguration>(); Configuration.ReplaceService <IUnitOfWorkFilterExecuter, NhUnitOfWorkFilterExecuter>(DependencyLifeStyle.Transient); IocManager.IocContainer.Register(Component.For <IInterceptor>().ImplementedBy <SheshaNHibernateInterceptor>().LifestyleTransient()); Configuration.Modules.AbpAspNetCore().CreateControllersForAppServices( this.GetType().Assembly, moduleName: "Shesha", useConventionalHttpVerbs: true); if (!SkipDbContextRegistration) { _nhConfig = Configuration.Modules.ShaNHibernate().NhConfiguration .DataBaseIntegration(db => { db.ConnectionString = !string.IsNullOrWhiteSpace(ConnectionString) ? ConnectionString : NHibernateUtilities.ConnectionString; db.Dialect <MsSql2012Dialect>(); db.Driver <Sql2008ClientDriver>(); db.Timeout = 150; /* * db.Timeout = string.IsNullOrEmpty(ConfigurationManager.AppSettings["SqlTimeoutInSeconds"]) * ? (byte)150 * : (byte)int.Parse(ConfigurationManager.AppSettings["SqlTimeoutInSeconds"]); */ db.LogFormattedSql = true; }) .SetProperty("hbm2ddl.keywords", "auto-quote") .CurrentSessionContext <UnitOfWorkSessionContext>(); // register filters _nhConfig.AddFilterDefinition(SoftDeleteFilter.GetDefinition()); _nhConfig.AddFilterDefinition(MayHaveTenantFilter.GetDefinition()); _nhConfig.AddFilterDefinition(MustHaveTenantFilter.GetDefinition()); var conventions = new Conventions(); var mappingAssemblies = new Dictionary <Assembly, string> { { typeof(UserToken).Assembly, "Abp" }, { typeof(UserLogin).Assembly, "Abp" } }; foreach (var item in mappingAssemblies) { conventions.AddAssembly(item.Key, item.Value); } var assembliesWithEntities = _assembleFinder.GetAllAssemblies() .Distinct(new AssemblyFullNameComparer()) .Where(a => !a.IsDynamic && a.GetTypes().Any(t => MappingHelper.IsEntity(t)) ) .ToList(); foreach (var assembly in assembliesWithEntities) { if (!conventions.AssemblyAdded(assembly)) { conventions.AddAssembly(assembly, assembly.GetCustomAttribute <TablePrefixAttribute>()?.Prefix); } } conventions.Compile(_nhConfig); } }