public void TestGlobal_CommandList() { CoreModule coreModule = new CoreModule(); coreModule.InitCommandList(); Assert.AreNotEqual(Global.CommandDict.Count, 0); }
private static ScheduleDefinition UtworzScheduleDefinition(Context context, Zadanie szablon) { var scheduleDefinition = new ScheduleDefinition(); using (var session = context.Session.Login.CreateSession(false, true, "ScheduleDefinition")) { var coreModule = CoreModule.GetInstance(session); var businessModule = BusinessModule.GetInstance(session); var taskDefinition = businessModule.TaskDefs.ByName["CfgNodes", "WysylkaMailiZWydrukiem"]; using (var transaction = session.Logout(true)) { scheduleDefinition.Name = $"Scheduler_{szablon.NumerPelny}"; scheduleDefinition.TaskDefinition = taskDefinition; coreModule.ScheduleDefs.AddRow(scheduleDefinition); transaction.CommitUI(); } session.Save(); } return(scheduleDefinition); }
public static Module sample(ModuleType type) { switch (type) { case ModuleType.Core: return(CoreModule.sample()); case ModuleType.Energy: return(EnergyModule.sample()); case ModuleType.Armor: return(ArmorModule.sample()); case ModuleType.Computation: return(ComputationModule.sample()); case ModuleType.Power: return(PowerModule.sample()); case ModuleType.Weapon: return(WeaponModule.sample()); case ModuleType.Repair: return(RepairModule.sample()); case ModuleType.Battery: return(BatteryModule.sample()); default: return(new Module(ModuleType.None, 0, 0, 0)); } }
private void LinphoneMainLoopHandler() { while (IsRunning) { CoreModule.linphone_core_iterate(LinphoneCore); Thread.Sleep(Constants.LC_SLEEP_TIMEOUT); } // Phone is disabled, free resources NetworkModule.linphone_nat_policy_unref(NatPolicy); CoreModule.linphone_core_unref(LinphoneCore); VTablePtr.Free(); TransportConfigPtr.Free(); registration_state_changed = null; call_state_changed = null; LinphoneCore = IntPtr.Zero; ProxyCfg = IntPtr.Zero; AuthInfo = IntPtr.Zero; TransportConfigPtr = IntPtr.Zero; coreLoop = null; Identity = null; ServerHost = null; RegistrationStateChangedEvent?.Invoke(LinphoneRegistrationState.LinphoneRegistrationCleared); }
public void TestGlobal_CommandList() { CoreModule coreModule = new CoreModule(); coreModule.InitCommandList(); Assert.AreNotEqual(EasyInject.Get <AppCenter>().CommandDict.Count, 0); }
public static void Initialize() { ContainerModule.Initialize(); CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); Atomic3DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); AtomicPlayer.PlayerModule.Initialize(); AtomicInterop.Initialize(); atomicsharp_initialize(); initSubsystems(); }
public LinphoneWrapper() { LoadLibraries(); Calls = new ConcurrentDictionary <IntPtr, LinphoneCall>(); CoreModule.linphone_core_set_log_level(OrtpLogLevel.END); }
private void InitializeComponent() { systemModule = new SystemModule(); systemAspNetModule = new SystemAspNetModule(); webModule = new WebModule(); sqlConnection1 = new SqlConnection(); cloneObjectModule1 = new CloneObjectModule(); reportsModule1 = new ReportsModule(); validationModule1 = new ValidationModule(); conditionalAppearanceModule1 = new ConditionalAppearanceModule(); stateMachineModule1 = new StateMachineModule(); coreModule1 = new CoreModule(); securityStrategyComplex1 = new SecurityStrategyComplex(); securityModule1 = new SecurityModule(); CoreAuthenticationApp1 = new CoreAuthentication(); ((ISupportInitialize)this).BeginInit(); // // sqlConnection1 // sqlConnection1.FireInfoMessageEventOnUserErrors = false; // // reportsModule1 // reportsModule1.EnableInplaceReports = true; reportsModule1.ReportDataType = typeof(ReportData); // // stateMachineModule1 // stateMachineModule1.StateMachineStorageType = typeof(XpoStateMachine); // // securityStrategyComplex1 // securityStrategyComplex1.Authentication = CoreAuthenticationApp1; securityStrategyComplex1.RoleType = typeof(Rol); securityStrategyComplex1.UserType = typeof(Usuario); // // CoreAspNetApplication // ApplicationName = "CORE"; LinkNewObjectToParentImmediately = false; CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema; Connection = sqlConnection1; Modules.Add(systemModule); Modules.Add(systemAspNetModule); Modules.Add(coreModule1); Modules.Add(cloneObjectModule1); Modules.Add(reportsModule1); Modules.Add(validationModule1); Modules.Add(conditionalAppearanceModule1); Modules.Add(stateMachineModule1); Modules.Add(webModule); Modules.Add(securityModule1); // TODO: migrate // CollectionsEditMode = ViewEditMode.Edit; Security = securityStrategyComplex1; DatabaseVersionMismatch += CoreAspNetApplication_DatabaseVersionMismatch; ((ISupportInitialize)this).EndInit(); }
/// <summary> /// Initializes the module. /// </summary> public static void Initialize() { #if NET try { bool isWebContext = false; var httpContextType = TypeCache.GetTypeWithoutAssembly("System.Web.HttpContext"); if (httpContextType != null) { var currentPropertyInfo = httpContextType.GetProperty("Current", BindingFlags.Public | BindingFlags.Static); if (currentPropertyInfo != null) { isWebContext = (currentPropertyInfo.GetValue(null, null) != null); } } Configuration config = null; if (isWebContext) { Log.Debug("Application is living in a web context, loading web configuration"); // All via reflection because we are support .NET 4.0 client profile, reflection equals this call: // config = Configuration.WebConfigurationManager.OpenWebConfiguration("~"); var webConfigurationManagerType = TypeCache.GetTypeWithoutAssembly("System.Web.Configuration.WebConfigurationManager"); var openWebConfigurationMethodInfo = webConfigurationManagerType.GetMethodEx("OpenWebConfiguration", new [] { typeof(string) }, allowStaticMembers: true); config = (Configuration)openWebConfigurationMethodInfo.Invoke(null, new [] { "~" }); } else { Log.Debug("Application is living in an application context, loading application configuration"); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); } if (config != null) { var configurationSection = config.GetSection <LoggingConfigurationSection>("logging", "catel"); if (configurationSection != null) { var logListeners = configurationSection.GetLogListeners(); foreach (var logListener in logListeners) { LogManager.AddListener(logListener); } } } } catch (Exception ex) { Log.Error(ex, "Failed to load log listeners from the configuration file"); } #endif var serviceLocator = ServiceLocator.Default; var module = new CoreModule(); module.Initialize(serviceLocator); }
public static void Initialize() { // Atomic Modules CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); #if ATOMIC_DESKTOP IPCModule.Initialize(); #endif AtomicAppModule.Initialize(); ScriptModule.Initialize(); AtomicNETScriptModule.Initialize(); AtomicNETNativeModule.Initialize(); PlayerModule.Initialize(); coreDelegates = new CoreDelegates(); coreDelegates.eventDispatch = NativeCore.EventDispatch; coreDelegates.updateDispatch = NativeCore.UpdateDispatch; IntPtr coreptr = csi_Atomic_NETCore_Initialize(ref coreDelegates); NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr)); if (core != null) { AtomicNET.RegisterSubsystem("NETCore", core); } context = core.Context; NativeCore.Initialize(); CSComponentCore.Initialize(); #if ATOMIC_DESKTOP string[] arguments = Environment.GetCommandLineArgs(); foreach (string arg in arguments) { AppBase.AddArgument(arg); } #endif }
public GraphQLServer(object app, GraphQLServerSettings settings = null) { App = app; Settings = settings ?? new GraphQLServerSettings(); CoreModule = new CoreModule(); IntrospectionModule = new IntrospectionModule(); RegisterModules(this.CoreModule, this.IntrospectionModule); RequestCache = new RequestCache(this.Settings); }
public void CoreModule() { var container = new DryIoc.Container(); var module = new CoreModule(container); module.Initialize(); container.Dispose(); }
// TODO: Break stop down into two-phases. Pre-stop alerts all modules about shutdown and does logging. // Stop will wait for all modules to indicate readiness or, after a timeout, force shutdown. public void Stop() { Log.LogInformation("Core is shutting down"); Modules.StopAll(this); CoreModule.Stop(); _started = false; // TODO: Should we publish a Stop event? Is anybody listening at this point? }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); RepositoryModule.Initialize(); CoreModule.Initialize(); Net.Framework.Entity.IocInstaller.Init(); //Net.General.Dependency.MVC.WindsorControllerFactory.Register(Assembly.GetExecutingAssembly()); GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }
static Program() { var builder = new ContainerBuilder(); var coreModule = new CoreModule(); builder.RegisterModule(coreModule); var appModule = new ApplicationModule(); builder.RegisterModule(appModule); Container = builder.Build(); Mapper.Initialize(x => x.ConstructServicesUsing(Container.Resolve)); }
public CrossStitchCore(NodeConfiguration configuration = null) { Configuration = configuration ?? NodeConfiguration.GetDefault(); NodeId = GetNodeId(Configuration); Name = GetFriendlyNodeName(Configuration, NodeId); MessageBus = new Acquaintance.MessageBus(); CoreModule = new CoreModule(this, MessageBus); Modules = new ModuleCollection(); Log = new ModuleLog(MessageBus, "Core"); }
protected override void Load(ContainerBuilder builder) { builder.RegisterModule(CoreModule.Configure().WithEncryptionFeature()); builder.RegisterModule(new UiFlowsMvcModule(this.GetType().Assembly)); builder.RegisterModule <ProfilerModule>(); builder.RegisterAssemblyTypes(GetType().Assembly) .Where(x => !typeof(IUiFlowScreen).IsAssignableFrom(x)) .AsImplementedInterfaces(); builder.RegisterAssemblyTypes(GetType().Assembly) .Where(x => typeof(IUiFlowScreen).IsAssignableFrom(x)) .AsSelf(); }
public static void LoadModules() { var assemblies = new List <Assembly> { typeof(CompositionRoot).Assembly }; var coreModule = new CoreModule(assemblies); Kernel.Load(coreModule); Kernel.Load <CommandBusModule>(); }
/// <summary> /// TODO: Добавить DI. /// </summary> static void Main(string[] args) { IConnectionStateManager connectionStateManager = new ConnectionStateManager(); IFileManager fileManager = new FileManager(new FileSystemService()); var apiController = new ApiController(); var settingsManager = new SettingsManager(); ISyncTableDataBase syncDb = new SyncTableDataBase(); IUserTableDataBase userDb = new UserTableDataBase(); var telegramService = new TelegramService(settingsManager.Settings.Token, settingsManager.Settings.Telegram_id); telegramService.Configure("/clean_folders", "clean empty folders", () => { var ls = userDb.GetAvailableFolders(); var removedList = fileManager.RemoveEmptyDirectories(ls); var sb = new StringBuilder(); sb.AppendLine("Removed dictionaries:"); sb.AppendJoin(Environment.NewLine, removedList); SendToTelegram(sb.ToString()); }); var syncModule = new CoreModule(fileManager, syncDb, connectionStateManager, userDb); syncModule.Initialize(apiController); syncModule.SendMessage += (o, s) => SendToTelegram(s); var attachModule = new FilesApi(new FilesService(connectionStateManager, syncDb), connectionStateManager); attachModule.Initialize(apiController); attachModule.SendMessage += (o, s) => SendToTelegram(s); var configModule = new ConfigurationModule(userDb, syncDb); configModule.Initialize(apiController); configModule.SendMessage += (o, s) => SendToTelegram(s); var ws = new WsService(connectionStateManager, apiController, IPAddress.Parse(settingsManager.Settings.IpAddress), settingsManager.Settings.HttpPort, settingsManager.Settings.HttpsPort); ws.Start(); void SendToTelegram(string message) { telegramService.SendTextMessageAsync(message); } // TODO: Добавить CancellationToken Console.ReadKey(true); ws.Stop(); }
protected void Application_Start() { Database.SetInitializer <ApplicationDbContext>(new AppDbInitializer()); GlobalConfiguration.Configure(WebApiConfig.Register); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); NinjectModule registrations = new CoreModule(); var kernel = new StandardKernel(registrations); DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); }
public static IContainer Configure() { var builder = new ContainerBuilder(); var coreModule = new CoreModule(); builder.RegisterModule(coreModule); var appModule = new ApplicationModule(); builder.RegisterModule(appModule); var container = builder.Build(); return(container); }
public static void Initialize() { // Atomic Modules CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); Atomic3DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); IPCModule.Initialize(); AtomicAppModule.Initialize(); ScriptModule.Initialize(); AtomicNETScriptModule.Initialize(); AtomicNETNativeModule.Initialize(); PlayerModule.Initialize(); coreDelegates = new CoreDelegates(); coreDelegates.eventDispatch = NativeCore.EventDispatch; coreDelegates.updateDispatch = NativeCore.UpdateDispatch; IntPtr coreptr = csb_Atomic_NETCore_Initialize(ref coreDelegates); NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr)); if (core != null) { AtomicNET.RegisterSubsystem("NETCore", core); } context = core.Context; NativeCore.Initialize(); CSComponentCore.Initialize(); }
public static void RegisterDependencies(HttpConfiguration config) { var builder = new ContainerBuilder(); var coreModule = new CoreModule(); builder.RegisterModule(coreModule); var webModule = new WebModule(); builder.RegisterModule(webModule); var container = builder.Build(); Mapper.Initialize(x => x.ConstructServicesUsing(container.Resolve)); RegisterMvcResolver(container, config); }
public Overlord() { this.CoreModule = new CoreModule(this); this.GlobalResourcesModule = new GlobalResourcesModule(this); this.ItemsModule = new ItemsModule(this); this.Modules.Add(this.CoreModule); this.Modules.Add(this.GlobalResourcesModule); this.Modules.Add(this.ItemsModule); this.Modules.Add(new ExpressionsModule(this)); this.Modules.Add(new CustomVarsModule(this)); this.Modules.Add(new ConditionsModule(this)); this.Modules.ForEach(a => { a.RegisterLogicConstructors(this); a.RegisterExpressionConstructors(this); a.RegisterLogicHandlers(this); }); }
/// <summary> /// Initializes the module. /// </summary> public static void Initialize() { #if NET try { var configurations = new List <Configuration>(); var exeConfig = GetExeConfiguration(); if (exeConfig != null) { configurations.Add(exeConfig); } var dllConfig = GetDllConfiguration(); if (dllConfig != null) { configurations.Add(dllConfig); } var configFilesHandled = new List <string>(); foreach (var configuration in configurations) { var configPath = configuration.FilePath.ToLower(); if (configFilesHandled.Contains(configPath)) { continue; } configFilesHandled.Add(configPath); LogManager.LoadListenersFromConfiguration(configuration); } } catch (Exception ex) { Log.Error(ex, "Failed to load log listeners from the configuration file"); } #endif var serviceLocator = ServiceLocator.Default; var module = new CoreModule(); module.Initialize(serviceLocator); }
public void GenerujEwidencjeSprzedazy() { CoreModule coreModule = CoreModule.GetInstance(Session); EwidencjaVatModule ewidencjaVatModule = EwidencjaVatModule.GetInstance(Session); KsiegaModule kasaModule = KsiegaModule.GetInstance(Session); using (ITransaction t = Session.Logout(true)) { foreach (var kontrahent in Kontrahenci) { // Utworzenie ewidencji sprzedaży i dodanie do tabeli ewidencji SprzedazEwidencja ewidencja = new SprzedazEwidencja(); coreModule.DokEwidencja.AddRow(ewidencja); // Ustawienie dat ewidencja.DataWplywu = Date.Today; ewidencja.DataDokumentu = Date.Today; ewidencja.DataOperacji = Date.Today; // Ustawienie numeru dokumentu, podmiotu i opisu ewidencja.NumerDokumentu = "FV/2007/123456"; ewidencja.Podmiot = kontrahent; ewidencja.Opis = "Faktura sprzedaży"; // Dodanie elementów VAT ElemEwidencjiVATSprzedaz elemVAT = new ElemEwidencjiVATSprzedaz(ewidencja); ewidencjaVatModule.EleEwidencjiVATT.AddRow(elemVAT); elemVAT.DefinicjaStawki = coreModule.DefStawekVat[StatusStawkiVat.Opodatkowana, new Percent(0.22m), false]; elemVAT.Netto = 1000m; // Płatności generują się automatycznie po każdej zmianie wartości ewidencji // Dodanie opisu analitycznego ElementOpisuEwidencji elemOpisu = new ElementOpisuEwidencji(ewidencja); kasaModule.OpisAnalityczny.AddRow(elemOpisu); elemOpisu.Wymiar = "Przychody"; elemOpisu.Symbol = "701-0"; elemOpisu.Kwota = 1000m; } t.Commit(); } }
/// <summary> /// Initializes the module. /// </summary> public static void Initialize() { #if NET try { var configurations = new List<Configuration>(); var exeConfig = GetExeConfiguration(); if (exeConfig != null) { configurations.Add(exeConfig); } var dllConfig = GetDllConfiguration(); if (dllConfig != null) { configurations.Add(dllConfig); } var configFilesHandled = new List<string>(); foreach (var configuration in configurations) { var configPath = configuration.FilePath.ToLower(); if (configFilesHandled.Contains(configPath)) { continue; } configFilesHandled.Add(configPath); LogManager.LoadListenersFromConfiguration(configuration); } } catch (Exception ex) { Log.Error(ex, "Failed to load log listeners from the configuration file"); } #endif var serviceLocator = ServiceLocator.Default; var module = new CoreModule(); module.Initialize(serviceLocator); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); }); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions( options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); services.AddFirebaseAuthentication(Configuration.GetValue <string>("Firebase:ProjectId")); if (Configuration.GetValue <bool>("UseLocalSignalR")) { services.AddSignalR(); } else { services.AddSignalR().AddAzureSignalR(); } services.AddHttpContextAccessor(); services.AddScoped <ICurrentUser, CurrentUser>(); BusinessLogicModule.ConfigureServices(services, Configuration); CommonModule.ConfigureServices(services); CoreModule.ConfigureServices(services); DataAccessModule.ConfigureServices(services, Configuration); }
//================================================================== // // Metoda, która tworzy w systemie nową definicję oświadczenia GIODO // //================================================================== public static void AddDefinicjaOświadczenie(Session session, string oswiadczenie, string trescZgody) { CoreModule core = CoreModule.GetInstance(session); using (ITransaction trans = session.Logout(true)) { GIODODefinicjaOświadczenia gIODODefinicja = new GIODODefinicjaOświadczenia(); core.GIODODefOswiadcz.AddRow(gIODODefinicja); gIODODefinicja.Oswiadczenie = oswiadczenie; gIODODefinicja.Rodzaj = RodzajeOświadczeńGIODO.UdzielenieZgody; gIODODefinicja.Pracownik = false; gIODODefinicja.OsobaFizyczna = true; gIODODefinicja.OsobaKontakowa = true; gIODODefinicja.Blokada = false; gIODODefinicja.Symbol = "GIODO"; gIODODefinicja.Tresc = trescZgody; trans.CommitUI(); } session.InvokeSaved(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //if (env.IsDevelopment()) //{ app.UseDeveloperExceptionPage(); //} BusinessLogicModule.ConfigureMiddleware(app); CommonModule.ConfigureMiddleware(app); CoreModule.ConfigureMiddleware(app); DataAccessModule.ConfigureMiddleware(app); // if (env.IsDevelopment()) // { app.UseCors("AllowAll"); // } app.UseAuthentication(); app.UseMvc(); if (Configuration.GetValue <bool>("UseLocalSignalR")) { app.UseSignalR(options => { options.MapHub <WorkspaceHub>("/workspaceHub"); options.MapHub <ChatHub>("/chatHub"); options.MapHub <NavigationHub>("/navigationHub"); }); } else { app.UseAzureSignalR(options => { options.MapHub <WorkspaceHub>("/workspaceHub"); options.MapHub <ChatHub>("/chatHub"); options.MapHub <NavigationHub>("/navigationHub"); }); } }
public void CreatePhone(LinphoneConnectionParams connectionParams) { IsRunning = true; registration_state_changed = new LinphoneDelegates.LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged); call_state_changed = new LinphoneDelegates.LinphoneCoreCallStateChangedCb(OnCallStateChanged); message_received = new LinphoneDelegates.LinphoneCoreCbsMessageReceivedCb(OnMessageReceived); VTable = CreateDefaultLinphoneCoreVTable(); VTablePtr = VTable.ToIntPtr(); LinphoneCore = CoreModule.linphone_core_new(VTablePtr, null, null, IntPtr.Zero); coreLoop = new Thread(LinphoneMainLoopHandler); coreLoop.IsBackground = false; coreLoop.Start(); TransportConfig = CreateTransportConfig(); TransportConfigPtr = TransportConfig.ToIntPtr(); NetworkModule.linphone_core_set_sip_transports(LinphoneCore, TransportConfigPtr); GenericModules.linphone_core_set_user_agent(LinphoneCore, connectionParams.Agent, connectionParams.Version); Identity = string.IsNullOrEmpty(connectionParams.AccountAlias) ? $"sip:{connectionParams.Username}@{connectionParams.Host}" : $"\"{connectionParams.AccountAlias}\" sip:{connectionParams.Username}@{connectionParams.Host}"; ServerHost = $"sip:{connectionParams.Host}:{connectionParams.Port}"; AuthInfo = GenericModules.linphone_auth_info_new(connectionParams.Username, null, connectionParams.Password, null, null, null); GenericModules.linphone_core_add_auth_info(LinphoneCore, AuthInfo); NatPolicy = CreateNatPolicy(connectionParams.NatPolicy); ProxyCfg = CreateProxyCfg(); CallParamsBuilder = new CallParamsBuilder(LinphoneCore); }
/// <summary> /// Initializes the module. /// </summary> public static void Initialize() { #if NET try { bool isWebContext = false; var httpContextType = TypeCache.GetTypeWithoutAssembly("System.Web.HttpContext"); if (httpContextType != null) { var currentPropertyInfo = httpContextType.GetProperty("Current", BindingFlags.Public | BindingFlags.Static); if (currentPropertyInfo != null) { isWebContext = (currentPropertyInfo.GetValue(null, null) != null); } } Configuration config = null; if (isWebContext) { Log.Debug("Application is living in a web context, loading web configuration"); // All via reflection because we are support .NET 4.0 client profile, reflection equals this call: // config = Configuration.WebConfigurationManager.OpenWebConfiguration("~"); var webConfigurationManagerType = TypeCache.GetTypeWithoutAssembly("System.Web.Configuration.WebConfigurationManager"); var openWebConfigurationMethodInfo = webConfigurationManagerType.GetMethodEx("OpenWebConfiguration", new [] { typeof(string) }, allowStaticMembers: true); config = (Configuration) openWebConfigurationMethodInfo.Invoke(null, new []{ "~" }); } else { Log.Debug("Application is living in an application context, loading application configuration"); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); } if (config != null) { var configurationSection = config.GetSection<LoggingConfigurationSection>("logging", "catel"); if (configurationSection != null) { var logListeners = configurationSection.GetLogListeners(); foreach (var logListener in logListeners) { LogManager.AddListener(logListener); } } } } catch (Exception ex) { Log.Error(ex, "Failed to load log listeners from the configuration file"); } #endif var serviceLocator = ServiceLocator.Default; var module = new CoreModule(); module.Initialize(serviceLocator); }