private void BuildServiceAgents()
        {
            _container.Register(Component.For <IDeviceStoreService>()
                                .Instance(new ServiceProxyFactory()
                                          .CreateServiceProxy <IDeviceStoreService>(
                                              new Uri("fabric:/Microsoft.SupplyChain.Cloud.Administration/DeviceStoreService")))
                                .LifestyleSingleton()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor"))
                                .Anywhere);

            _container.Register(Component.For <ISmartContractStoreService>()
                                .Instance(new ServiceProxyFactory()
                                          .CreateServiceProxy <ISmartContractStoreService>(
                                              new Uri("fabric:/Microsoft.SupplyChain.Cloud.Administration/SmartContractStoreService")))
                                .LifestyleSingleton()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor"))
                                .Anywhere);

            _container.Register(Component.For <IDeviceStoreServiceAgent>()
                                .ImplementedBy <DeviceStoreServiceAgent>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());

            _container.Register(Component.For <ISmartContractStoreServiceAgent>()
                                .ImplementedBy <SmartContractStoreServiceAgent>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());
        }
Пример #2
0
 private void BuildControllers()
 {
     _container.Register(Component.For <DiscoveryController>()
                         .ImplementedBy <DiscoveryController>()
                         .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                         .LifestyleTransient());
 }
Пример #3
0
        private void OnComponentRegistered(string key, IHandler handler)
        {
            AnyInterceptorAttribute anyInterceptorAttribute = null;

            bool isAnyIterceptor = handler.ComponentModel.Implementation.GetInterfaces().Any(i =>
            {
                return(i.GetCustomAttributes(true).Any(a =>
                {
                    if (a is AnyInterceptorAttribute)
                    {
                        anyInterceptorAttribute = a as AnyInterceptorAttribute;
                        return true;
                    }
                    return false;
                }));
            });

            if (isAnyIterceptor && anyInterceptorAttribute != null && !string.IsNullOrWhiteSpace(anyInterceptorAttribute.InterceptorName))
            {
                if (handler.ComponentModel.Interceptors.Count <= 0 || !handler.ComponentModel.Interceptors.Any(i => i.ToString().Equals(anyInterceptorAttribute.InterceptorName, StringComparison.OrdinalIgnoreCase)))
                {
                    handler.ComponentModel.Interceptors.Add(InterceptorReference.ForKey(anyInterceptorAttribute.InterceptorName));
                }
            }
        }
 private void BuildProcessors()
 {
     _container.Register(Component.For <IEventProcessor>()
                         .ImplementedBy <GenericEventProcessor>()
                         .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                         .LifestyleSingleton());
 }
Пример #5
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(
         Component.For <IMessageQueueService>()
         .ImplementedBy <MessageQueueService>()
         .LifestyleTransient()
         .Interceptors(InterceptorReference.ForKey("LogAspect")).First
         .Interceptors(InterceptorReference.ForKey("EFDBEntityValidationExceptionAspect")).Anywhere,
         Component.For <IMessageQueueServiceFactory>().AsFactory());
 }
Пример #6
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 => container.Register(
     Component.For <IInterceptor>()
     .ImplementedBy <ErrorHandlerInterceptor>()
     .Named("XInterceptor"),
     Component.For <IBeanCounter>()
     .ImplementedBy <BeanCounter>()
     .Interceptors(
         InterceptorReference.ForKey("XInterceptor")).Anywhere,
     Component.For <TextWriter>().Instance(_logWriter));
Пример #7
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For <IAnalyzeTextStrategyFactory>()
                .ImplementedBy <AnalyzeTextStrategyFactory>()
                .LifeStyle
                .Singleton
#if DEBUG
                .Interceptors(InterceptorReference.ForKey("performanceMetricInterceptor")).Anywhere
#endif
                );
        }
Пример #8
0
 void RegisterUsingContainer(IWindsorContainer container)
 {
     container
     .Register(Classes.FromAssembly(_apiDomainServicesAssembly).BasedOn <IDomainService>()
               .Configure(
                   cr =>
     {
         var x =
             cr.Interceptors(InterceptorReference.ForKey(LoggingConstants.DomainServiceLogger)).Anywhere;
     })
               .WithServiceFromInterface());
 }
        public virtual void BuildCommands()
        {
            _container.Register(Component.For <ICommandAbstractFactory>()
                                .ImplementedBy <CommandAbstractFactory>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleSingleton());

            _container.Register(Component.For <ICommand <RetrieveTrackingTransactionsContext> >()
                                .ImplementedBy <RetrieveTrackingTransactionsCommand>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());
        }
Пример #10
0
        public virtual void BuildCommands()
        {
            _container.Register(Component.For <ICommandAbstractFactory>()
                                .ImplementedBy <CommandAbstractFactory>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleSingleton());

            _container.Register(Component.For <ICommand <GenerateIoTSecurityTokenContext> >()
                                .ImplementedBy <GenerateIoTSecurityTokenCommand>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());
        }
Пример #11
0
        public void DynamicProxy_With_Windsor()
        {
            var container = new WindsorContainer();

            container.Register(Component.For <TransactionAspect>().Named("test"));
            container.Register(Component
                               .For <ICommandHandler <MyCommand> >()
                               .ImplementedBy <MyCommanHandler>()
                               .Interceptors(InterceptorReference.ForKey("test")).Anywhere);

            ICommandHandler <MyCommand> commandHandler = container.Resolve <ICommandHandler <MyCommand> >();

            commandHandler.Handle(new MyCommand());
        }
Пример #12
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Classes.FromThisAssembly()
                               .BasedOn <IHttpController>()
                               .LifestylePerWebRequest());

            var cacheInterceptor = new[] { InterceptorReference.ForKey("CacheInterceptor") };


            container.Register(
                Component.For <IInterceptor>().ImplementedBy <CacheResultInterceptor>().Named("CacheInterceptor"),
                Component.For <ICacheProvider>().ImplementedBy <MemoryCacheProvider>().LifestyleSingleton(),
                Component.For <YoutubeAPIService>().ImplementedBy <YoutubeAPIServiceImpl>().Interceptors(
                    cacheInterceptor).First
                );
        }
        public virtual void BuildCommands()
        {
            _container.Register(Component.For <ICommandAbstractFactory>()
                                .ImplementedBy <CommandAbstractFactory>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleSingleton());

            _container.Register(Component.For <ICommand <IoTHubSubscriberContext> >()
                                .ImplementedBy <IoTHubSubscriberCommand>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());

            _container.Register(Component.For <ICommand <BlockchainContractBootstrapperContext> >()
                                .ImplementedBy <BlockchainContractBootstrapperCommand>()
                                .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                .LifestyleTransient());
        }
        public override void RegisterInterceptor(Type modelType, ContentDataInterceptor interceptor)
        {
            Validator.ThrowIfNull("type", (object)modelType);
            Validator.ThrowIfNull("interceptor", (object)interceptor);

            lock (SyncRoot)
            {
                if (IsInterceptableType(modelType))
                {
                    var    interceptorType         = interceptor.GetType();
                    string interceptorReferenceKey = interceptorType.Name + modelType.AssemblyQualifiedName;

                    if (!Container.Kernel.HasComponent(interceptorReferenceKey))
                    {
                        Container.Register(
                            Component.For <IInterceptor>().ImplementedBy(interceptorType).LifeStyle.Singleton.Named(interceptorReferenceKey));
                    }

                    if (!Container.Kernel.HasComponent(modelType))
                    {
                        Container.Register(
                            Component
                            .For(modelType)
                            .ImplementedBy(modelType)
                            .LifeStyle.Transient
                            .Interceptors(
                                InterceptorReference.ForKey(interceptorReferenceKey),
                                InterceptorReference.ForType <EPiPropertiesInterceptor>())
                            .SelectedWith(ContentProxyInterceptorSelector)
                            .Anywhere
                            .Proxy.Hook(ServiceLocator.Current.GetInstance <ContentDataInterceptorHook>()
                                        ) /* !!! */
                            );
                    }
                }
                else
                {
                    if (!Container.Kernel.HasComponent(modelType))
                    {
                        Container.Register(Component.For(modelType).ImplementedBy(modelType).LifeStyle.Transient);
                    }
                }

                RegisterPropertyInterceptor();
            }
        }
        public void ProcessModel(IKernel kernel, ComponentModel model)
        {
            ImplementationInfo implementationInfo = new ImplementationInfo(model.Implementation);

            if ((_compositeLoggerInternal.TypeRegistered(model.Implementation)) ||
                model.Services.Any(_compositeLoggerInternal.TypeRegistered))
            {
                model.Interceptors.Add(InterceptorReference.ForKey(_loggerInterceptorComponentName));
                implementationInfo.InterceptorAdded = true;
                model.Services.ForEach(implementationInfo.AddService);
            }
            else
            {
                implementationInfo.InterceptorAdded = false;
            }

            ProcessedImplementations.Add(model.Implementation, implementationInfo);
        }
Пример #16
0
        static void Main(string[] args)
        {
            using (system = ActorSystem.Create("akka-performance-demo"))
            {
                var registeredMonitor = ActorMonitoringExtension.RegisterMonitor(system, new Monitor());

                IWindsorContainer container = new WindsorContainer();
                container.Register(Component.For <IInterceptor>().
                                   ImplementedBy <MonitorInterceptor>().
                                   Named("monitorInterceptor"),
                                   Component.For <HelloActor>().
                                   LifestyleTransient().
                                   Interceptors(InterceptorReference.ForKey("monitorInterceptor")).
                                   Anywhere);

                WindsorDependencyResolver propsResolver =
                    new WindsorDependencyResolver(container, system);

                var hello = system.ActorOf(propsResolver.Create <HelloActor>(), "Worker1");

                hello.Tell("What's Up");
                hello.Tell("Goodbye");

                var count = 20;
                while (count >= 0)
                {
                    ActorMonitoringExtension.Monitors(system).IncrementDebugsLogged();
                    Console.WriteLine("Logging debug...");
                    Thread.Sleep(100);
                    count--;
                }

                while (ManualResetEvent.WaitOne())
                {
                    Console.WriteLine("Shutting down...");
                    system.Shutdown();
                    Console.WriteLine("Shutdown complete");
                    Console.WriteLine("Press any key to exit");
                    Console.ReadKey();
                    return;
                }
            }
        }
Пример #17
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Run 2 - configuration fluent");
            using (var container = new WindsorContainer())
            {
                container.AddFacility <LoggingFacility>(f => f.UseNLog());

                container.Register(
                    Component.For <IInterceptor>()
                    .ImplementedBy <LogAspect>()
                    .Named("LogAspect"));
                container.Register(
                    Component.For <ISomething>()
                    .ImplementedBy <Something>()
                    .Interceptors(InterceptorReference.ForKey("LogAspect")).Anywhere);
                var something = container.Resolve <ISomething>();
                something.DoSomething("");
                Console.WriteLine("Augment 10 returns " + something.Augment(10));
                something.DoSomething(new Record(1.0, 2.0, "Hello World", 3.0));
            }
        }
Пример #18
0
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            container.Register(Component.For <IInterceptor>()
                               .ImplementedBy <ServiceLoggerInterceptor>()
                               .Named("ServiceLoggingInteceptor"));

            container.Register(Classes.FromAssemblyContaining <CustomerService>()
                               .BasedOn(typeof(BaseService <>))
                               .WithService.DefaultInterfaces()
                               .LifestyleTransient()
                               .Configure(delegate(ComponentRegistration c) { var x = c.Interceptors(InterceptorReference.ForKey("ServiceLoggingInteceptor")).Anywhere; })
                               );
        }
Пример #19
0
        static void Main(string[] args)
        {
            #region Sample2
            IWindsorContainer container2 = new WindsorContainer();
            container2.Register(Component.For <ILogger>().ImplementedBy <ConsoleWithTimeLogger>().LifestyleSingleton());

            var logger = container2.Resolve <ILogger>();
            logger.Debug("Frank");
            //ILogger logger = WindsorInit.GetContainer().Resolve<ILogger>();
            //logger.Debug("记录日志");
            Console.ReadKey();
            #endregion

            #region Sample1

            IWindsorContainer container = new WindsorContainer();
            container.Register(Classes.FromAssembly(Assembly.GetExecutingAssembly()).BasedOn <IUserResoistory>().WithServiceAllInterfaces());
            container.Register(Component.For <IInterceptor>().ImplementedBy <ApplicationInterceptor>().Named("myinterceptor"));
            container.Register(Component.For <IUserApplication>().ImplementedBy <UserApplication>().Interceptors(InterceptorReference.ForKey("myinterceptor")).Anywhere);

            var userApplication = container.Resolve <IUserApplication>();

            userApplication.Show();

            Console.ReadKey();

            #endregion
        }
 public override IEnumerable <InterceptorReference> GetExpectedInterceptorsInCorrectOrder()
 {
     yield return(InterceptorReference.ForKey("interceptorKey"));
 }
Пример #21
0
 public AopTest()
 {
     aspectCoreProvider = new ServiceCollection()
                          .AddTransient <ISum, SumAspectCore>()
                          .BuildServiceContextProvider();
     nornsUrdProvider = new ServiceCollection()
                        .AddTransient <ISum, SumNornsUrd>()
                        .ConfigureAop()
                        .BuildServiceProvider();
     castleProvider = new WindsorContainer();
     castleProvider.Register(Component.For <CastleAddAInterceptor>().Named("test"));
     castleProvider.Register(Component.For <ISum>().ImplementedBy <Sum>().Interceptors(InterceptorReference.ForKey("test")).Anywhere);
     provider = new ServiceCollection().AddTransient <ISum, SumWithAddA>()
                .BuildServiceProvider();
 }
Пример #22
0
 static void KernelComponentRegistered(string key, IHandler handler)
 {
     if (TypesNotToIntercept.Any(type => type.IsAssignableFrom(implementation));
         return;
     handler.ComponentModel.Interceptors.AddIfNotInCollection(InterceptorReference.ForKey("SomeInterceptor"));
 }
Пример #23
0
        private static void Main1(string[] args)
        {
            var container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));

            container.Register(Component.For <ConsoleLoggerInterceptor>().LifeStyle.Singleton.Named("consoleLogger"));
            container.Register(
                Component.For <IUsersContainer>()
                .ImplementedBy <InDbUsersContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IOrdersContainer>()
                .ImplementedBy <InDbOrdersContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IServiceInfoContainer>()
                .ImplementedBy <InDbServicesContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IRolesContainer>()
                .ImplementedBy <InDbRolesContainer>()
                .LifestyleSingleton());

            container.BeginScope();

            var ordersContainer   = container.Resolve <IOrdersContainer>();
            var usersContainer    = container.Resolve <IUsersContainer>();
            var servicesContainer = container.Resolve <IServiceInfoContainer>();
            var rolesContainer    = container.Resolve <IRolesContainer>();

            container.Register(
                Component.For <IUsersOperations>()
                .ImplementedBy <UserOperations>()
                .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere
                .LifestyleSingleton());

            container.Register(
                Component.For <IServicesOperations>()
                .ImplementedBy <ServiceOperations>()
                .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere
                .LifestyleSingleton());

            var userOperations     = container.Resolve <IUsersOperations>();
            var servicesOperations = container.Resolve <IServicesOperations>();

            var mainMenu    = new Menu();
            var clientMenu  = new Menu();
            var managerMenu = new Menu();
            var adminMenu   = new Menu();

            mainMenu.AddCommand(new EnterCommand("Вход", usersContainer, new[] { adminMenu, managerMenu, clientMenu }));
            mainMenu.AddCommand(new RegistrationCommand("Регистрация", usersContainer, rolesContainer, mainMenu));

            clientMenu.AddCommand(new OrderServiceCommand("Заказать услугу", servicesContainer, userOperations, clientMenu));
            clientMenu.AddCommand(new CancelOrderCommand("Отменить заказ", userOperations, ordersContainer, clientMenu));
            clientMenu.AddCommand(new PayServiceCommand("Оплатить услугу", userOperations, ordersContainer, clientMenu));
            clientMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            managerMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, managerMenu));
            managerMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, managerMenu));
            managerMenu.AddCommand(new ChangeServiceCommand("Изменить услугу", servicesOperations, servicesContainer, managerMenu));
            managerMenu.AddCommand(new ViewStatisticPerClientCommand("Посмотреть статистику по клиентам", ordersContainer, usersContainer, managerMenu));
            managerMenu.AddCommand(new ViewAttendanceStatiscticsCommand("Статистика заказов", ordersContainer, managerMenu));
            managerMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            adminMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllUnpaidServicesCommand("Посмотреть все неоплаченные услуги", ordersContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllUsersCommand("Посмотреть всех пользователей", usersContainer, adminMenu));
            adminMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            mainMenu.Print();
            mainMenu.SetCommand(mainMenu.ReadCommand());
            mainMenu.Run();
        }
Пример #24
0
    public static void Main(String [] args)
    {
        var container = new WindsorContainer();

        container.Register(Component.For <TestInterceptor>().Named("test"));
        container.Register(Component.For <InnerInterface>().ImplementedBy <InnerClass>().Interceptors(InterceptorReference.ForKey("test")).Anywhere);
        // this row below will throw the exception
        var innerClassInstance = container.Resolve <InnerInterface>();
    }
Пример #25
0
 /// <summary>
 /// Installs the specified container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="store">The store.</param>
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(Component.For <ILibraryApp>().ImplementedBy <LibraryApp>().Interceptors(InterceptorReference.ForKey("Trace")).Anywhere.LifestyleTransient());
 }
Пример #26
0
        private static void Main(string[] args)
        {
            var roles = new[]
            {
                new Role {
                    Name = "Администратор"
                },
                new Role {
                    Name = "Управляющий"
                },
                new Role {
                    Name = "Клиент"
                },
            };

            var users = new List <User>
            {
                new User {
                    Id = Guid.NewGuid().ToString(), Fio = "Петров П.П", Login = "******", Password = "******", Role = roles[2]
                },
                new User {
                    Id = Guid.NewGuid().ToString(), Fio = "Смирнов П.П", Login = "******", Password = "******", Role = roles[0]
                },
                new User {
                    Id = Guid.NewGuid().ToString(), Fio = "Симонов П.П", Login = "******", Password = "******", Role = roles[1]
                },
                new User {
                    Id = Guid.NewGuid().ToString(), Fio = "Иванов П.П", Login = "******", Password = "******", Role = roles[2]
                },
                new User {
                    Id = Guid.NewGuid().ToString(), Fio = "Сидоров П.П", Login = "******", Password = "******", Role = roles[2]
                },
            };

            var availableServices = new List <ServiceInfo>
            {
                new ServiceInfo {
                    Id          = Guid.NewGuid().ToString(), Name = "Спа", CostPerUnit = 1000,
                    Measurement = "час.", IsDeprecated = false
                },
                new ServiceInfo {
                    Id          = Guid.NewGuid().ToString(), Name = "Бильярд восьмёрка", CostPerUnit = 2000,
                    Measurement = "час", IsDeprecated = false
                },
                new ServiceInfo {
                    Id          = Guid.NewGuid().ToString(), Name = "Бильярд девятка", CostPerUnit = 2000,
                    Measurement = "час", IsDeprecated = false
                },
                new ServiceInfo {
                    Id          = Guid.NewGuid().ToString(), Name = "Русский бильярд", CostPerUnit = 2000,
                    Measurement = "час", IsDeprecated = false
                }
            };

            var container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));

            container.Register(Component.For <ConsoleLoggerInterceptor>().LifeStyle.Singleton.Named("consoleLogger"));

            container.Register(Component
                               .For <IEnumerable <User> >()
                               .Instance(users)
                               .LifestyleSingleton());

            container.Register(Component
                               .For <IEnumerable <Role> >()
                               .Instance(roles)
                               .LifestyleSingleton());

            container.Register(Component
                               .For <IEnumerable <ServiceInfo> >()
                               .Instance(availableServices)
                               .LifestyleSingleton());

            container.Register(
                Component.For <IUsersContainer>()
                .ImplementedBy <InMemoryUsersContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IOrdersContainer>()
                .ImplementedBy <InMemoryOrdersContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IServiceInfoContainer>()
                .ImplementedBy <InMemoryServicesContainer>()
                .LifestyleSingleton());

            container.Register(
                Component.For <IRolesContainer>()
                .ImplementedBy <InMemoryRolesContainer>()
                .LifestyleSingleton());

            var ordersContainer   = container.Resolve <IOrdersContainer>();
            var usersContainer    = container.Resolve <IUsersContainer>();
            var servicesContainer = container.Resolve <IServiceInfoContainer>();
            var rolesContainer    = container.Resolve <IRolesContainer>();

            container.Register(
                Component.For <IUsersOperations>()
                .ImplementedBy <UserOperations>()
                .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere
                .LifestyleSingleton());

            container.Register(
                Component.For <IServicesOperations>()
                .ImplementedBy <ServiceOperations>()
                .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere
                .LifestyleSingleton());

            var userOperations     = container.Resolve <IUsersOperations>();
            var servicesOperations = container.Resolve <IServicesOperations>();


            var mainMenu    = new Menu();
            var clientMenu  = new Menu();
            var managerMenu = new Menu();
            var adminMenu   = new Menu();

            mainMenu.AddCommand(new EnterCommand("Вход", usersContainer, new[] { adminMenu, managerMenu, clientMenu }));
            mainMenu.AddCommand(new RegistrationCommand("Регистрация", usersContainer, rolesContainer, mainMenu));

            clientMenu.AddCommand(new OrderServiceCommand("Заказать услугу", servicesContainer, userOperations, clientMenu));
            clientMenu.AddCommand(new CancelOrderCommand("Отменить заказ", userOperations, ordersContainer, clientMenu));
            clientMenu.AddCommand(new PayServiceCommand("Оплатить услугу", userOperations, ordersContainer, clientMenu));
            clientMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            managerMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, managerMenu));
            managerMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, managerMenu));
            managerMenu.AddCommand(new ChangeServiceCommand("Изменить услугу", servicesOperations, servicesContainer, managerMenu));
            managerMenu.AddCommand(new ViewStatisticPerClientCommand("Посмотреть статистику по клиентам", ordersContainer, usersContainer, managerMenu));
            managerMenu.AddCommand(new ViewAttendanceStatiscticsCommand("Статистика заказов", ordersContainer, managerMenu));
            managerMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            adminMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllUnpaidServicesCommand("Посмотреть все неоплаченные услуги", ordersContainer, adminMenu));
            adminMenu.AddCommand(new ViewAllUsersCommand("Посмотреть всех пользователей", usersContainer, adminMenu));
            adminMenu.AddCommand(new ExitCommand("Выход", mainMenu));

            mainMenu.Print();
            mainMenu.SetCommand(mainMenu.ReadCommand());
            mainMenu.Run();
        }
Пример #27
0
        private static void ConfigureCastlerWindsor(HttpConfiguration config)
        {
            var container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, true));
            container.Kernel.Resolver.AddSubResolver(new AppSettingsStringConvention());
            container.Kernel.Resolver.AddSubResolver(new AppSettingsUriConvention());
            container.Kernel.Resolver.AddSubResolver(new AppSettingsPasswordFormatConvention());

            container.AddFacility <LoggingFacility>(f => f.ConfiguredExternally());

            container.Register(
                Component.For <IInterceptor>().ImplementedBy <LogInterceptor>().Named("LogInterceptor"),
                Classes.FromAssemblyNamed("Test.Api.Business")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleSingleton()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.Core")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleSingleton()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.Producers")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleSingleton()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api")
                .BasedOn <IHttpController>()
                .WithServiceSelf()
                .LifestyleTransient()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.Handler")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleTransient()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.HyperMedia")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleTransient()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.Data")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleTransient()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromAssemblyNamed("Test.Api.Services")
                .Pick()
                .WithServiceAllInterfaces()
                .LifestyleTransient()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }),
                Classes.FromThisAssembly()
                .BasedOn <IHtmlResponseBuilder>()
                .WithServiceAllInterfaces()
                .LifestyleSingleton()
                .Configure(r => { var x = r.Interceptors(InterceptorReference.ForKey("LogInterceptor")).Anywhere; }));


            config.DependencyResolver = new WindsorResolver(container);
        }
Пример #28
0
        public static StatelessService CreateService(StatelessServiceContext context)
        {
            // pass in dependencies as there is no other way to do it with the SF c# sdk.
            var configurationPackage = context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            var documentDbSection    = configurationPackage.Settings.Sections["DocumentDB"].Parameters;
            var uri = documentDbSection["DocumentDBEndpointUri"].Value;

            if (string.IsNullOrEmpty(uri))
            {
                throw new ArgumentNullException("DocumentDBEndpointUri", "DocumentDBEndpointUri is not set in Service Fabric configuration package.");
            }

            var documentDbPrimaryKey = documentDbSection["DocumentDBPrimaryKey"].Value;

            if (string.IsNullOrEmpty(documentDbPrimaryKey))
            {
                throw new ArgumentNullException("DocumentDBPrimaryKey", "DocumentDBPrimaryKey is not set in Service Fabric configuration package.");
            }

            var blockchainSection                = configurationPackage.Settings.Sections["Blockchain"].Parameters;
            var transactionNodeVip               = blockchainSection["TransactionNodeVip"].Value;
            var blockchainAdminAccount           = blockchainSection["BlockchainAdminAccount"].Value;
            var blockchainAdminAccountPassphrase = blockchainSection["BlockchainAdminPassphrase"].Value;

            var documentClient = new DocumentClient(new Uri(uri), documentDbPrimaryKey);

            ITrackerStoreRepository trackerStoreRepository = new TrackerStoreRepository(documentClient);

            ServiceLocator.Current.GetInstance <IWindsorContainer>().Register(Component.For <ITrackerStoreRepository>().Instance(trackerStoreRepository));

            Web3 web3 = new Web3(transactionNodeVip);
            IDeviceMovementServiceAgent deviceMovementServiceAgent = new EthereumDeviceMovementServiceAgent(web3, blockchainAdminAccount, blockchainAdminAccountPassphrase, ServiceLocator.Current.GetInstance <ISmartContractStoreServiceAgent>());

            ServiceLocator.Current.GetInstance <IWindsorContainer>().Register(Component.For <IDeviceMovementServiceAgent>()
                                                                              .Instance(deviceMovementServiceAgent)
                                                                              .Interceptors(InterceptorReference.ForKey("ConsoleInterceptor")).Anywhere
                                                                              .LifestyleTransient());

            var service = new TrackingStoreService(context, trackerStoreRepository);

            ServiceLocator.Current.GetInstance <IWindsorContainer>().Register(Component.For <ITrackingStoreService>().Instance(service));
            return(service);
        }