Ejemplo n.º 1
0
        protected override void RegisterTypes(IUnityContainer container)
        {
            base.RegisterTypes(container);
            var config = new AuthorizationConfiguration <MyDefaultAuthorizer>();

            config.AddNamespaceAuthorizer <MyAppAuthorizer>("MyApp");
            config.AddNamespaceAuthorizer <MyCluster1Authorizer>("MyApp.MyCluster1");
            config.AddNamespaceAuthorizer <MyBar1Authorizer>("MyApp.MyCluster1.Bar1");

            container.RegisterInstance <IAuthorizationConfiguration>(config, (new ContainerControlledLifetimeManager()));
            container.RegisterType <IFacetDecorator, AuthorizationManager>("AuthorizationManager", new ContainerControlledLifetimeManager());

            var reflectorConfig = new ReflectorConfiguration(
                new[] {
                typeof(Bar1),
                typeof(Bar2),
                typeof(Foo1),
                typeof(Foo2)
            },
                new[] {
                typeof(SimpleRepository <Bar1>),
                typeof(SimpleRepository <Bar2>),
                typeof(SimpleRepository <Foo1>),
                typeof(SimpleRepository <Foo2>),
            },
                new[] { typeof(Bar1).Namespace, typeof(Bar2).Namespace, typeof(Foo2).Namespace });

            container.RegisterInstance <IReflectorConfiguration>(reflectorConfig, new ContainerControlledLifetimeManager());
        }
Ejemplo n.º 2
0
        protected override void RegisterTypes(IServiceCollection services)
        {
            base.RegisterTypes(services);
            var config = new AuthorizationConfiguration <MyDefaultAuthorizer>();

            config.AddNamespaceAuthorizer <MyAppAuthorizer>("MyApp");
            config.AddNamespaceAuthorizer <MyCluster1Authorizer>("MyApp.MyCluster1");
            config.AddNamespaceAuthorizer <MyBar1Authorizer>("MyApp.MyCluster1.Bar1");

            services.AddSingleton <IAuthorizationConfiguration>(config);
            services.AddSingleton <IFacetDecorator, AuthorizationManager>();
        }
        public void TestCreateOk()
        {
            var config = new AuthorizationConfiguration <ITypeAuthorizer <object> >();

            config.AddNamespaceAuthorizer <INamespaceAuthorizer>("1");
            config.AddTypeAuthorizer <object, ITypeAuthorizer <object> >();

            // ReSharper disable once UnusedVariable
            var sink = new AuthorizationManager(config);
        }