public static void RegisterPongApplicationServices() { DependencyFactory.RegisterType <IPongMessageService, PongMessageService>(); var service = DependencyFactory.Container.Resolve(typeof(PongMessageService), "PongMessageService"); DependencyFactory.RegisterInstance <IPongMessageService>((IPongMessageService)service); }
/// <summary> /// CTOR /// </summary> public MainWindowViewModel() { // Initialize commands this.InitializeCommands(); // Read config file IConfigurationFile configFile = this.LoadApplicationConfigFile(); // Register EventAggregator DependencyFactory.RegisterInstance <IEventAggregator>(GeneralConstants.EventAggregator, new EventAggregator()); // Register services DependencyFactory.RegisterInstance <ILocalizerService>(ServiceNames.LocalizerService, new LocalizerService("de-DE")); //TODO: Add debug mode. When enabled register OHW Debug Service, otherwise OHW Service as normal DependencyFactory.RegisterInstance <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementDebugService, new OpenHardwareMonitorManagementServiceDebug()); DependencyFactory.RegisterInstance <IOpenHardwareMonitorManagementService>(ServiceNames.OpenHardwareMonitorManagementService, new OpenHardwareMonitorManagementService()); DependencyFactory.RegisterInstance <IHardwareInformationService>(ServiceNames.WmiHardwareInformationService, new WmiHardwareInfoService()); DependencyFactory.RegisterInstance <IExceptionReporterService>(ServiceNames.ExceptionReporterService, new ExceptionReporterService()); DependencyFactory.RegisterInstance <ILoggingService>(ServiceNames.LoggingService, new LoggingServiceNLog()); DependencyFactory.RegisterInstance <IFanControllerService>(ServiceNames.MainboardFanControllerService, new MainboardFanControllerService()); // Start Fan-Controller-Service DependencyFactory.Resolve <IFanControllerService>(ServiceNames.MainboardFanControllerService).Start(); // Application title string appVersion = DependencyFactory.Resolve <ILocalizerService>(ServiceNames.LocalizerService).GetLocalizedString("MainWindowTitle"); this.ApplicationTitle = String.Format(appVersion, Assembly.GetEntryAssembly().GetName().Version.ToString()); // Create appearance ViewModel DependencyFactory.RegisterInstance <AppearanceViewModel>(GeneralConstants.ApperanceViewModel, new AppearanceViewModel()); }
/// <summary> /// Load configuration file /// </summary> /// <returns></returns> private IConfigurationFile LoadApplicationConfigFile() { // Create config file IConfigurationFile configFile = new XmlConfigurationFile(DirectoryConstants.ApplicationConfig); if (!configFile.Load()) { // Add section GeneralSettings configFile.Sections.Add("GeneralSettings"); this.CheckGeneralSettings(configFile); // Add tile settings configFile.Sections.Add("TileSettings"); this.CheckTileSettings(configFile); } else { // Check general settings this.CheckGeneralSettings(configFile); // Check tile settings this.CheckTileSettings(configFile); } // Save config file configFile.Save(); // Register global application file DependencyFactory.RegisterInstance <IConfigurationFile>(ConfigFileNames.ApplicationConfig, configFile); return(configFile); }
/// <summary> /// Initializes the Yupi Emulator. /// </summary> public Server() { SetupLogger(); if (CryptoSettings.Instance.Enabled) { Encryption.GetInstance(new Crypto.Cryptography.RSACParameters(RSACUtils.Base64ToBigInteger(CryptoSettings.Instance.RsaD), RSACUtils.Base64ToBigInteger(CryptoSettings.Instance.RsaN), RSACUtils.Base64ToBigInteger(CryptoSettings.Instance.RsaE)), CryptoSettings.Instance.DHKeysSize); } var factory = ModelHelper.CreateFactory(); // TODO: Close Session & Multiple sessions! var dbSession = factory.OpenSession(); DependencyFactory.RegisterInstance(dbSession); DependencyFactory.RegisterInstance(factory); Router.Default = new Router(GameSettings.Instance.Release, "../../../Config/", typeof(AchievementProgressMessageComposer).Assembly ); ClientManager = DependencyFactory.Resolve <ClientManager>(); RestServer = new WebServer(); SetupTCP(); }
private static IUnityContainer BuildUnityContainer() { Container = DependencyFactory.Container; DependencyFactory.RegisterInstance(new DatabaseProviderFactory().CreateDefault()); DependencyFactory.RegisterType <IDataContext, DataContext>(); DependencyFactory.RegisterType <IDadosUsuarioRepositorio, DadosUsuarioRepositorio>(); DependencyFactory.RegisterType <IDadosFacade, DadosFacade>(); return(Container); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services, ILoggerFactory loggerFactory) { loggerFactory.AddLog4Net(); services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); }); var keyConfig = new KeyConfig(); var tokenConfig = new JwtConfiguration(); Configuration.GetSection("TokenConfiguration").Bind(tokenConfig); DependencyFactory.RegisterInstance(services, keyConfig, tokenConfig); services.AddAuthentication(authOptions => { authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; authOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(bearerOptions => { var paramsValidation = bearerOptions.TokenValidationParameters; paramsValidation.IssuerSigningKey = keyConfig.Key; paramsValidation.ValidAudience = tokenConfig.Audience; paramsValidation.ValidIssuer = tokenConfig.Issuer; paramsValidation.ValidateIssuerSigningKey = true; paramsValidation.ValidateLifetime = true; paramsValidation.ClockSkew = TimeSpan.Zero; }); services.AddAuthorization(auth => { auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder() .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser().Build()); }); services.AddDbContext <EntityFrameworkContext>(options => options.UseSqlServer(Configuration.GetConnectionString("EQSDBCONNECTION"))); services.AddMvc(options => { options.Filters.Add(new ExceptionHandlingFilter()); }); services.AddAutoMapper(); services.AddMvc(); services.AddSwaggerGen(c => { c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description = "Please enter JWT with Bearer into field", Name = "Authorization", Type = "token" }); c.SwaggerDoc("v1", new Info { Title = "EQS Access Control API", Version = "v1" }); c.DescribeAllEnumsAsStrings(); }); }