protected override void Load(ContainerBuilder builder)
        {
            var selenoHost = new SelenoHost();

            selenoHost.Run("ContosoUniversity", 12365,
                           c => c.WithRouteConfig(RouteConfig.RegisterRoutes));
            builder.RegisterInstance(selenoHost).AsSelf().SingleInstance();
            builder.RegisterType <WebUiDriver>().AsSelf();

            DependenciesConfig.ConfigureDependencies(builder);
            //builder.RegisterGeneric(typeof(ViewStudentDetailsScenario))
            //    .AsSelf()
            //    .PropertiesAutowired()
            //    .InstancePerLifetimeScope();

            builder.RegisterSource(new ContravariantRegistrationSource());
            builder.RegisterAssemblyTypes(typeof(IMediator).Assembly).AsImplementedInterfaces();
            builder.RegisterAssemblyTypes(typeof(FunctionalTestsAutofacModule).Assembly).AsImplementedInterfaces();
            builder.Register <SingleInstanceFactory>(ctx =>
            {
                var c = ctx.Resolve <IComponentContext>();
                return(t => c.Resolve(t));
            });
            builder.Register <MultiInstanceFactory>(ctx =>
            {
                var c = ctx.Resolve <IComponentContext>();
                return(t => (IEnumerable <object>)c.Resolve(typeof(IEnumerable <>).MakeGenericType(t)));
            });

            builder.RegisterType <StudentDetailsPage>().As(typeof(IPage <Student>));
        }
Exemplo n.º 2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     DependenciesConfig.RegisterDependencies();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Exemplo n.º 3
0
        private static void InitializePhotoService()
        {
            var dependencyResolver = DependenciesConfig.RegisterDependencies();

            var photoService = dependencyResolver.GetService <IPhotoService>();

            photoService.CreateAndConfigureAsync();
        }
Exemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            var container = DependenciesConfig.Register(System.Web.Http.GlobalConfiguration.Configuration);

            //global
            AreaRegistration.RegisterAllAreas();
            System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemplo n.º 5
0
        public void SelfRegistrationTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <ExampleClass1, ExampleClass1>(true);
            provider = new DependencyProvider(config);
            ExampleClass1 actual = provider.Resolve <ExampleClass1>();

            Assert.IsNotNull(actual);
        }
Exemplo n.º 6
0
        public void InstancePerDependencyTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <IExample, ExampleClass1>(false);
            provider = new DependencyProvider(config);
            IExample expected = provider.Resolve <IExample>();
            IExample actual   = provider.Resolve <IExample>();

            Assert.AreNotEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void SingletonTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <IExample, ExampleClass1>(true);
            provider = new DependencyProvider(config);
            IExample expected = provider.Resolve <IExample>();
            IExample actual   = provider.Resolve <IExample>();

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void CreateDependencyTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <IExample, ExampleClass1>(false);
            config.Register <IExample, ExampleClass2>(true);
            provider = new DependencyProvider(config);
            IExample actual = provider.Resolve <IExample>();

            Assert.IsNotNull(actual);
        }
Exemplo n.º 9
0
        // Para obtener más información sobre cómo configurar la autenticación, visite https://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            DependenciesConfig.Config(app);
            //// Configure el contexto de base de datos, el administrador de usuarios y el administrador de inicios de sesión para usar una única instancia por solicitud
            //app.CreatePerOwinContext(ApplicationDbContext.Create);
            //app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
            //app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Permitir que la aplicación use una cookie para almacenar información para el usuario que inicia sesión
            // y una cookie para almacenar temporalmente información sobre un usuario que inicia sesión con un proveedor de inicio de sesión de terceros
            // Configurar cookie de inicio de sesión
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Permite a la aplicación validar la marca de seguridad cuando el usuario inicia sesión.
                    // Es una característica de seguridad que se usa cuando se cambia una contraseña o se agrega un inicio de sesión externo a la cuenta.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <UserService, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Permite que la aplicación almacene temporalmente la información del usuario cuando se verifica el segundo factor en el proceso de autenticación de dos factores.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Permite que la aplicación recuerde el segundo factor de verificación de inicio de sesión, como el teléfono o correo electrónico.
            // Cuando selecciona esta opción, el segundo paso de la verificación del proceso de inicio de sesión se recordará en el dispositivo desde el que ha iniciado sesión.
            // Es similar a la opción Recordarme al iniciar sesión.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Quitar los comentarios de las siguientes líneas para habilitar el inicio de sesión con proveedores de inicio de sesión de terceros
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
Exemplo n.º 10
0
        public void OpenGenericTypeTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <IRepository, MyRepository>(false);
            config.Register(typeof(ServiceImpl <>), typeof(ServiceImpl <>), false);
            provider = new DependencyProvider(config);
            ServiceImpl <IRepository> actual = provider.Resolve <ServiceImpl <IRepository> >();

            Assert.IsNotNull(actual);
            Assert.AreEqual(111, actual.GetNum());
        }
Exemplo n.º 11
0
        public void UnityContainer_AfterDependencyRegistration_ContainsAllContracts()
        {
            var exportedTypes = GetTypesExportedFromAssembly();
            var actualTypes   = new List <Type>();
            var container     = MockUnityContainer(actualTypes);

            DependenciesConfig.RegisterAllDependencies(container);
            var unexpectedTypes = actualTypes.Except(exportedTypes).ToArray();
            var missingTypes    = exportedTypes.Except(actualTypes).ToArray();

            Assert.That(unexpectedTypes, Is.Empty, "There are more types registered to the container than expected.");
            Assert.That(missingTypes, Is.Empty, "Some of the types are not registered.");
        }
Exemplo n.º 12
0
        public void GetSomeImplementationsTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <IExample, ExampleClass1>(true);
            config.Register <IExample, ExampleClass2>(false);
            provider = new DependencyProvider(config);
            IEnumerable <IExample> actual = provider.Resolve <IEnumerable <IExample> >();

            Assert.IsNotNull(actual);
            Assert.AreEqual(2, ((IList)actual).Count);
        }
Exemplo n.º 13
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectModule registrations = new DependenciesConfig();
            var           kernel        = new StandardKernel(registrations);

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));

            Logging.InitLogger();
        }
Exemplo n.º 14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            DependenciesConfig.RegisterDependencies();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DocumentFileService documentFileService = new DocumentFileService(new Logger());

            //OJOOO activar
            documentFileService.CreateAndConfigureAsync();

            DbConfiguration.SetConfiguration(new SiccoApp.Persistence.SiccoAppConfiguration());
        }
Exemplo n.º 15
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            DependenciesConfig.RegisterDependencies();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            PhotoService photoService = new PhotoService(new Logger());

            photoService.CreateAndConfigureAsync();

            DbConfiguration.SetConfiguration(new MyFixIt.Persistence.EFConfiguration());
        }
Exemplo n.º 16
0
        public void CycleDependencyTest()
        {
            DependencyProvider provider;
            DependenciesConfig config = new DependenciesConfig();

            config.Register <ExampleClass1, ExampleClass1>(false);
            config.Register <ExampleClass2, ExampleClass2>(true);
            config.Register <ExampleClass3, ExampleClass3>(true);

            provider = new DependencyProvider(config);
            ExampleClass1 actual = provider.Resolve <ExampleClass1>();

            Assert.IsNotNull(actual);
            Assert.AreEqual(null, actual.example.example.example);
        }
        public void Setup()
        {
            DependenciesConfig config = new DependenciesConfig();

            config.Register <ISimpleDependency, SimpleDependency>();
            config.Register <ISimpleDependency, SimpleWithInnerDependency>();
            config.Register <ISingleton, SingletonDependency>(LifeCycle.Singleton);
            config.Register <ICollectionDependency, CollectionClass1>();
            config.Register <ICollectionDependency, CollectionClass2>();
            config.Register <ICollectionDependency, CollectionClass3>();
            config.Register <IInnerCollection, InnerCollectionClass>();
            config.Register <IConstrained, ConstrainedClass>();
            config.Register <IGenericConstrained <IConstrained>, GenericConstrainedClass <IConstrained> >();
            config.Register <IOpenConstrained, OpenConstrainedClass>();
            config.Register(typeof(IOpenGeneric <>), typeof(OpenGenericConstrainedClass <>));
            config.Register <ISimpleDependency, AnotherSimpleClass>();

            container = new DIContainer(config);
        }
        protected override void Load(ContainerBuilder builder)
        {
            DependenciesConfig.ConfigureDependencies(builder);

            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);


            builder.Register(c => new MvcControllerDriver(routes)
            {
                Container = c.Resolve <Specify.IContainer>()
            })
            .AsSelf()
            .InstancePerLifetimeScope();

            //builder.Register(c => new AutofacContainer(c.Resolve<ILifetimeScope>()))
            //    .As<IContainer>()
            //    .InstancePerLifetimeScope();
        }
Exemplo n.º 19
0
        protected override void Load(ContainerBuilder builder)
        {
            DependenciesConfig.ConfigureDependencies(builder);
            builder.RegisterGeneric(typeof(ViewControllerScenario <,>))
            .AsSelf()
            .PropertiesAutowired()
            .InstancePerLifetimeScope();

            builder.RegisterSource(new ContravariantRegistrationSource());
            builder.RegisterAssemblyTypes(typeof(IMediator).Assembly).AsImplementedInterfaces();
            builder.RegisterAssemblyTypes(typeof(AcceptanceTestsAutofacModule).Assembly).AsImplementedInterfaces();
            builder.Register <SingleInstanceFactory>(ctx =>
            {
                var c = ctx.Resolve <IComponentContext>();
                return(t => c.Resolve(t));
            });
            builder.Register <MultiInstanceFactory>(ctx =>
            {
                var c = ctx.Resolve <IComponentContext>();
                return(t => (IEnumerable <object>)c.Resolve(typeof(IEnumerable <>).MakeGenericType(t)));
            });
        }
Exemplo n.º 20
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();


            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            GlobalConfiguration.Configure(WebApiConfig.Register);

            //https://haacked.com/archive/2011/03/19/fixing-binding-to-decimals.aspx/
            ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());
            ModelBinders.Binders.Add(typeof(int), new IntegerModelBinder());


            //https://stackoverflow.com/questions/793459/how-to-set-decimal-separators-in-asp-net-mvc-controllers
            //ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            //ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());



            //https://blog.murilogomes.com/2015/03/24/globalizing-datetime-and-decimal-in-asp-net-mvc-using-modelbinder/
            //System.Web.Mvc.ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());

            //ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
            //ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder());

            DependenciesConfig.RegisterDependencies();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DbConfiguration.SetConfiguration(new ProductQuoteApp.Persistence.ProductQuoteAppConfiguration());

            //Para los mensaje de error se muestren en el idioma correcto dependiendo de Culture.
            ClientDataTypeModelValidatorProvider.ResourceClassKey = "Messages";
            DefaultModelBinder.ResourceClassKey = "Messages";

            DbInterception.Add(new ProductQuoteAppInterceptorLogging());
        }
Exemplo n.º 21
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            IContainer container = new Container();

            container = container.WithMvc(
                throwIfUnresolved: type => type.IsController()
                );

            DependenciesConfig.RegisterDependencies(container);
            DeloitteHostingEnvironment.Set((relativeUrl) =>
            {
                if (HostingEnvironment.IsDevelopmentEnvironment)
                {
                    relativeUrl = "\\bin" + relativeUrl;
                }
                return(HostingEnvironment.MapPath(relativeUrl));
            });
        }
Exemplo n.º 22
0
        protected void ConfigureDependencies(IServiceCollection services)
        {
            var connectionString = Configuration.GetConnectionString("localDb");

            DependenciesConfig.ConfigureDependencies(services, connectionString);
        }
Exemplo n.º 23
0
        protected void ConfigureDependencies(IServiceCollection services)
        {
            var connectionString = Configuration.GetConnectionString("Default");

            DependenciesConfig.ConfigureDependencies(services, this.Configuration, connectionString);
        }
Exemplo n.º 24
0
        private void RegisterDependencies(IServiceCollection services)
        {
            var connectionString = Configuration.GetConnectionString("NotifyDatabase");

            DependenciesConfig.ConfigureDependencies(services, connectionString);
        }