public void CreateClass() { var classesToCreate = new List <string> { "Yoav1", "Yoav2" }; var folderPath = "/Users/yoavhagashi/Project/IOCTest/WindsorIoc"; var builder = new ClassBuilder(); var writer = new ClassWriter(); var windsorContainerFactory = new WindsorContainerFactory(); var constractorParams = new Dictionary <string, string>(); foreach (var className in classesToCreate) { var newClass = builder.Build("WindsorIoc", className, true, constractorParams); var path = Path.Join(folderPath, $"{className}.cs"); writer.Write(path, newClass); constractorParams.Add($"I{className}", className); } var containerTestMethod = windsorContainerFactory.Build("container", constractorParams); var windsorContainerTestnewClass = builder.Build("WindsorIoc", "WindsorContainer", true, null, new Dictionary <string, string> { { "TestContainer", containerTestMethod } }); var pathWindsorContainerTest = Path.Join(folderPath, $"WindsorContainerTest.cs"); writer.Write(pathWindsorContainerTest, windsorContainerTestnewClass); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); var container = new WindsorContainerFactory().CreateContainer(); var tasks = container.ResolveAll <IStartupTask>(); tasks.ForEach(t => t.Run()); }
private const int MaximumNumberOfCommands = 5; // this value should come from a config file private static void Main(string[] args) { var container = WindsorContainerFactory.Create(MaximumNumberOfCommands); var roverController = container.Resolve <MarsRoverController>(); roverController.RaiseLocationReport += controller_RaiseLocationReport; DisplayControlInstructions(); ReceiveCommands(roverController); }
protected void Application_Start() { TelemetryConfiguration.Active.DisableTelemetry = true; AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var container = WindsorContainerFactory.Current(new ServiceInstaller()); var castleControllerFactory = new WindsorControllerFactory(container); ControllerBuilder.Current.SetControllerFactory(castleControllerFactory); }
private IWindsorContainer GetSut() { _containerToDisposeAfterTest = WindsorContainerFactory.Create(); return(_containerToDisposeAfterTest); }
public IServiceProvider ConfigureServices(IServiceCollection services) { // Mvc services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddMvcOptions(mvc => { mvc.Filters.Add(new ValidationExceptionFilter()); }) .AddJsonOptions(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); // Dbcontext & repo services.AddDbContext <DbContext, PmContext>(ctx => ctx.UseSqlServer(Configuration.GetConnectionString("Database"))); services.AddRepository(); services.AddSingleton <IDatabaseInformation, ConnectionStringDatabaseInformation>(); services.AddTransient <PmContext>(); services.Configure <IdentityOptions>(c => { // Password settings c.Password.RequireDigit = true; c.Password.RequiredLength = 8; c.Password.RequireNonAlphanumeric = false; c.Password.RequireUppercase = true; c.Password.RequireLowercase = false; c.Password.RequiredUniqueChars = 6; // Lockout settings c.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30); c.Lockout.MaxFailedAccessAttempts = 10; c.Lockout.AllowedForNewUsers = true; // User settings c.User.RequireUniqueEmail = true; }); services.AddTransient <UserManager <User> >(); // Authentication services.AddIdentity <User, IdentityRole>() .AddEntityFrameworkStores <PmContext>() .AddDefaultTokenProviders(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(c => { c.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Issuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])) }; }); // Swagger services.AddHttpContextAccessor(); services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "API", Version = "v1" })); services.ConfigureSwaggerGen(c => { c.CustomSchemaIds(x => x.FullName); c.AddSecurityDefinition("Bearer", new ApiKeyScheme() { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > { { "Bearer", new string[] { } } }); }); // Httpclients services.AddHttpClient <IPhoneClient, MessageBirdClient>(c => { c.BaseAddress = new Uri("https://rest.messagebird.com/"); c.DefaultRequestHeaders.Add("Authorization", string.Format($"AccessKey {Configuration.GetSection("Messagebird:ApiKey").Value}")); }); var windsorContainer = WindsorContainerFactory.GetContainer(typeof(Startup).Assembly); var windsorServiceProvider = WindsorRegistrationHelper.CreateServiceProvider(windsorContainer, services); return(windsorServiceProvider); }
public void SetUp() { _windsorContainer = WindsorContainerFactory.Create(); }
public void SetUp() { Container = new WindsorContainerFactory().Create(); Database = Container.Resolve <MongoDatabase>(); }