public void LoadWithWrongAssemblyOrType_ReturnsNull(string data)
        {
            var loader = new ServerFactoryLoader(new ServerFactoryActivator(ServicesFactory.Create()));
            IServerFactoryAdapter serverFactory = loader.Load(data);

            Assert.Null(serverFactory);
        }
Exemple #2
0
        public ViewResult GetCategories()
        {
            var service = ServicesFactory.GetCategoriesService();
            var model   = service.GetCategoriesModel();

            return(View(model));
        }
Exemple #3
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <param name="startup">Startup function used to configure the OWIN pipeline.</param>
        /// <param name="options">Settings to control the startup behavior of an OWIN application</param>
        protected void Configure(Action <IAppBuilder> startup, StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory     = new TestServerFactory();
            IServiceProvider services = ServicesFactory.Create();
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(testServerFactory);
            context.Startup       = startup;
            _started = engine.Start(context);
            _next    = testServerFactory.Invoke;
        }
Exemple #4
0
        public void RunServer(StartOptions options)
        {
            if (options == null)
            {
                return;
            }

            // get existing loader factory services
            string appLoaderFactories;

            if (!options.Settings.TryGetValue(typeof(IAppLoaderFactory).FullName, out appLoaderFactories) ||
                !string.IsNullOrEmpty(appLoaderFactories))
            {
                // use the built-in AppLoaderFactory as the default
                appLoaderFactories = typeof(AppLoaderFactory).AssemblyQualifiedName;
            }

            // prepend with our app loader factory
            options.Settings[typeof(IAppLoaderFactory).FullName] =
                typeof(AppLoaderWrapper).AssemblyQualifiedName + ";" + appLoaderFactories;

            DefaultHost host = null;

            if (options.Settings.ContainsKey("devMode"))
            {
                host = new DefaultHost(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, watchFiles: true);

                host.OnChanged += () =>
                {
                    Environment.Exit(250);
                };
            }
            else
            {
                host = new DefaultHost(AppDomain.CurrentDomain.SetupInformation.ApplicationBase);
            }

            using (_hostContainer.AddHost(host))
            {
                WriteLine("Starting with " + GetDisplayUrl(options));

                // Ensure the DefaultHost is available to the AppLoaderWrapper
                IServiceProvider container = ServicesFactory.Create(options.Settings, services =>
                {
                    services.Add(typeof(ITraceOutputFactory), () => new NoopTraceOutputFactory());
                    services.Add(typeof(DefaultHost), () => host);
                });

                IHostingStarter starter = container.GetService <IHostingStarter>();
                using (starter.Start(options))
                {
                    WriteLine("Started successfully");

                    WriteLine("Press Enter to exit");
                    Console.ReadLine();

                    WriteLine("Terminating.");
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Start the component
        /// </summary>
        public void Start()
        {
            if (string.IsNullOrWhiteSpace(this.configuration.BackendAddress))
            {
                throw new ArgumentException("Unable to start DashboardBackend when no BackendUrl is specified");
            }

            var services = (ServiceProvider)ServicesFactory.Create();
            var options  = new StartOptions
            {
                Urls =
                {
                    this.configuration.BackendAddress
                },
                AppStartup = typeof(Startup).FullName
            };

            // Pass through the IJobbrServiceProvider to allow Startup-Classes to let them inject this dependency
            services.Add(typeof(IJobbrServiceProvider), () => this.dependencyResolver);

            var hostingStarter = services.GetService <IHostingStarter>();

            this.webHost = hostingStarter.Start(options);

            Logger.InfoFormat($"Started OWIN-Host for DashboardBackend at '{this.configuration.BackendAddress}'.");
        }
Exemple #6
0
        public MainWindowFormViewModel()
        {
            ClickAddUserInProjectCommand   = new RelayCommand(arg => ClickMethodAddUserInProject());
            ClickBuildErModelCommand       = new RelayCommand(arg => ClickMethodBuildErModel());
            ClickChangeQuerryCommand       = new RelayCommand(arg => ClickMethodChangeQuerry());
            ClickAutorizationCommand       = new RelayCommand(arg => ClickMethodAutorization());
            ClickAddConnectionCommand      = new RelayCommand(arg => ClickMethodAddConection());
            ClickSaveExcelCommand          = new RelayCommand(arg => ClickMethodSaveExcel());
            ClickSaveTxtCommand            = new RelayCommand(arg => ClickMethodSaveTxt());
            ClickSavePdfCommand            = new RelayCommand(arg => ClickMethodSavePdf());
            ClickSendQuerryToEmailCommand  = new RelayCommand(arg => ClickMethodSendQuerryToEmail());
            ClickRefreshQuerryCommand      = new RelayCommand(arg => ClickMethodRefreshQuerryCommand());
            ClickDeleteRowCommand          = new RelayCommand(arg => ClickMethodDeleteRowCommand());
            ClickRunQuerryCommand          = new RelayCommand(arg => ClickMethodRunQuerryCommand());
            MainWindowData.UserConnections = new ObservableCollection <Group>();
            CanExecute   = false;
            _currentUser = new User();
            FirstName    = "SignIn please";

            var servicesFactory = new ServicesFactory();

            _projectService = servicesFactory.GetProjectService();

            //_builder = new BuilderBL.SQLDesigner.QueryBuilder(new DbSchema());
            //SqlQuerry = MainWindowData.SqlQuerry;
            //MessageBox.Show("For using  all functionality of the application, you have to register or sign-in");
        }
Exemple #7
0
        public static void RunServer(StartOptions options)
        {
            if (options == null)
            {
                return;
            }

            string boot;

            if (!options.Settings.TryGetValue("boot", out boot) ||
                string.IsNullOrWhiteSpace(boot))
            {
                options.Settings["boot"] = "Domain";
            }

            ResolveAssembliesFromDirectory(
                Path.Combine(Directory.GetCurrentDirectory(), "bin"));

            WriteLine("Starting with " + GetDisplayUrl(options));

            IServiceProvider services = ServicesFactory.Create();
            var         starter       = services.GetService <IHostingStarter>();
            IDisposable server        = starter.Start(options);

            WriteLine("Started successfully");

            WriteLine("Press Enter to exit");
            Console.ReadLine();

            WriteLine("Terminating.");

            server.Dispose();
        }
Exemple #8
0
        public frmManager()
        {
            InitializeComponent();

            pm            = PackageManager.GetInstance();
            bm            = BoxsManager.GetInstance();
            serverService = ServicesFactory.GetInstance().GetServerService();
            enu           = bm.BoxsDictionary.GetEnumerator();
            dataGridView1.AllowUserToAddRows = false;

            DataGridViewDisableButtonColumn openCol = new DataGridViewDisableButtonColumn();

            openCol.Name = openColName;
            DataGridViewDisableButtonColumn deletePackageCol = new DataGridViewDisableButtonColumn();

            deletePackageCol.Name = deletePackageColName;
            DataGridViewDisableButtonColumn boxStateCol = new DataGridViewDisableButtonColumn();

            boxStateCol.Name = boxStateColName;

            dataGridView1.Columns.Add(openCol);
            dataGridView1.Columns.Add(deletePackageCol);
            dataGridView1.Columns.Add(boxStateCol);
            Initialize();
            UpdateData();
        }
        public JsonResult GetPartialModel(ChannelInfoModel channelInfo)
        {
            var service = ServicesFactory.GetTweetsService();
            var model   = service.GetPartialTweetsModel(channelInfo.ChannelId, channelInfo.ChannelName);

            return(Json(new { status = "ok", model = model }));
        }
Exemple #10
0
        public ViewResult GetChannels()
        {
            var service = ServicesFactory.GetChannelsService();
            var model   = service.GetChannelsModel();

            return(View(model));
        }
Exemple #11
0
        private void Configure(Action <IAppBuilder> startup, StartOptions options = null)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory     = new OwinEmbeddedServerFactory();
            IServiceProvider services = ServicesFactory.Create(
                serviceProvider => serviceProvider.AddInstance <ITraceOutputFactory>(new NullTraceOutputFactory())
                );
            var engine  = services.GetService <IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup       = startup
            };

            _started = engine.Start(context);
            _next    = testServerFactory.Invoke;
        }
Exemple #12
0
        public override void OnActionExecuting(HttpActionContext filterContext)
        {
            //  Get API key provider
            var provider = ServicesFactory.GetTokenServices();

            if (filterContext.Request.Headers.Contains(Token))
            {
                var tokenValue = filterContext.Request.Headers.GetValues(Token).First();

                // Validate Token
                if (provider != null && !provider.ValidateToken(tokenValue))
                {
                    var responseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                    {
                        ReasonPhrase = "Invalid Request"
                    };
                    filterContext.Response = responseMessage;
                }
            }
            else
            {
                filterContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
            }

            base.OnActionExecuting(filterContext);
        }
Exemple #13
0
        private async void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (var client = ServicesFactory.CreateForWebRequest <Test.ITestService>("https://127.0.0.1:5001/api/test"))
                {
                    client.DisableSSL = true;

#if (USAGE1)
                    var test1 = await client.Service.Test("ac");

                    var test2 = await client.Service.Test2(new Test.TestData()
                    {
                        test = 12
                    });
#elif (USAGE2)
                    var test1 = await client.Service.Test("ac");

                    var test2 = await client.Service.Test2(new Test.TestData()
                    {
                        test = 12
                    });
#endif
                    label1.Text = $"{test1} {test2.test}";
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Exemple #14
0
        private void Configure(AzureServiceBusOwinServiceConfiguration config, Action <IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var options = new StartOptions();

            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var serverFactory = new AzureServiceBusOwinServerFactory(config);
            var services      = ServicesFactory.Create();
            var engine        = services.GetService <IHostingEngine>();
            var context       = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(serverFactory),
                Startup       = startup
            };

            _started = engine.Start(context);
        }
Exemple #15
0
        static int Main(string[] args)
        {
            if (args.Length >= 2)
            {
                Usage();
                return(0);
            }

            string arg;

            if (args.Length == 1)
            {
                arg = args[0];
                if (arg == "help" || arg == "-help" || arg == "--help")
                {
                    Usage();
                    return(0);
                }
            }
            else
            {
                var portStr = Environment.GetEnvironmentVariable("PORT");
                int port;
                if (portStr != null && int.TryParse(portStr, out port))
                {
                    arg = string.Format("http://localhost:{0}/", port);
                }
                else
                {
                    arg = "http://localhost:5000/";
                }
            }

            try
            {
                var options = new StartOptions(arg);
                options.Settings["boot"] = "Domain";
                using (ServicesFactory.Create().GetService <IHostingStarter>().Start(options))
                {
                    Console.WriteLine(arg);

                    var resetEvent = new ManualResetEvent(false);
                    Console.CancelKeyPress += (sender, e) =>
                    {
                        e.Cancel = true;
                        resetEvent.Set();
                    };

                    resetEvent.WaitOne();
                    Console.WriteLine("Disposing...");
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(1);
            }
        }
 private static IServiceProvider BuildServices(StartOptions options)
 {
     if (options.Settings != null)
     {
         return(ServicesFactory.Create(options.Settings));
     }
     return(ServicesFactory.Create());
 }
Exemple #17
0
        public RegistrationFormViewModel()
        {
            ClickCloseCommand = new RelayCommand(arg => ClickCloseMethod());

            var servicesFactory = new ServicesFactory();

            _userService = servicesFactory.GetUserService();
        }
Exemple #18
0
        public void Load()
        {
            this.Initialize();
            this.boxControlService = ServicesFactory.GetInstance().GetBoxControlService();
            this.boxControlService.Init();

            CLog4net.LogInfo("BoxsManager is Loaded");
        }
Exemple #19
0
        private IServiceProvider CreateServiceFactory()
        {
            var provider = (ServiceProvider)ServicesFactory.Create();

            provider.Add(typeof(ITraceOutputFactory), typeof(OwinTraceOutputFactory));

            return(provider);
        }
Exemple #20
0
        private static IDisposable Start(StartContext context, IListen listener)
        {
            IServiceProvider services = ServicesFactory.Create();
            var engine = services.GetService <IHostingEngine>();

            context.ServerFactory = new ServerFactoryAdapter(new CustomListenerHostFactory(listener));
            return(engine.Start(context));
        }
        public override Func <Type, object> CreateContainer()
        {
            IServiceProvider services = ServicesFactory.Create(reg => reg
                                                               .Add <IAppLoaderFactory, TestAppLoader1>()
                                                               .Add <IAppLoaderFactory, TestAppLoader2>());

            return(services.GetService);
        }
Exemple #22
0
        public Point(Customer customer)
        {
            this.Customer = customer;

            ITrafficService service = ServicesFactory.CreateTrafficServcie();

            Traffics = service.GetListOfTrafficsFilteredByNumber(customer.Number);
        }
        public static ServiceProvider Create()
        {
            var provider = (ServiceProvider)ServicesFactory.Create();

            provider.Add(typeof(ITraceOutputFactory), typeof(OwinTraceOutputFactory));

            return(provider);
        }
Exemple #24
0
        public FrmMain()
        {
            CLog4net.LogInfo("System starting!");

            InitializeComponent();
            this.systemController = new SystemController();
            FrmLoading frmLoading = new FrmLoading(this.systemController);

            frmLoading.ShowDialog();

            if (frmLoading.DialogResult == DialogResult.OK)
            {
                frmLoading.Hide();
                frmLoading.Close();
            }

            this.boxsManager      = BoxsManager.GetInstance();
            this.packageManager   = PackageManager.GetInstance();
            this.voiceService     = ServicesFactory.GetInstance().GetVoicService();
            this.serverService    = ServicesFactory.GetInstance().GetServerService();
            this.cameraService    = ServicesFactory.GetInstance().GetCameraService();
            this.about            = AboutConfig.GetInstance().GetAbout();
            this.infoCenterLister = InfoCenterLister.GetInsatnce();
            this.adManager        = ADManager.GetInstance();

            this.AddUCScene(Roster.Home, new Home(this, 0));
            this.AddUCScene(Roster.P_ControlPanel, new PostmanControlPanel(this, 5));
            this.AddUCScene(Roster.P_D_Verify, new PostmanVerify(this, 60));
            this.AddUCScene(Roster.P_D_ChooseBox, new PostmanChooseBox(this, 60));
            this.AddUCScene(Roster.P_D_DeliverPG, new PostmanDeliverPG(this, 120));
            this.AddUCScene(Roster.P_D_EntryPGInfo, new PostmanEntryPGInfo(this, 60));
            this.AddUCScene(Roster.P_D_PGVerify, new PostmanPGVerify(this, 60));
            this.AddUCScene(Roster.P_D_FinishWork, new PostmanFinishWork(this, 10));
            this.AddUCScene(Roster.P_D_Cancel, new PostmanCancelTask(this, 60));
            this.AddUCScene(Roster.P_D_CancelTask, new PostmanCancelTask(this, 60));
            this.AddUCScene(Roster.P_T_EntryPGInfo, new PostmanTBEntryPGInfo(this, 60));
            this.AddUCScene(Roster.P_T_FinishWork, new PostmanTBFinishWork(this, 60));
            this.AddUCScene(Roster.P_S_PGDelivered, new PostmanSPGDelivered(this, 60));
            this.AddUCScene(Roster.P_R_PGRegister, new PostmanRegister(this, 180));

            this.AddUCScene(Roster.C_ControlPanel, new CustomerControlPanel(this, 5));
            this.AddUCScene(Roster.C_T_Verify, new CustomerTBVerify(this, 60));
            this.AddUCScene(Roster.C_T_FinishWork, new CustomerTBFinishWork(this, 60));
            this.AddUCScene(Roster.C_S_EntryPGInfo, new CustomerSEntryPGInfo(this, 60));
            this.AddUCScene(Roster.C_S_PGSearched, new CustomerPGSearched(this, 60));

            this.AddUCScene(Roster.A_Verify, new AdminVerify(this, 60));
            this.AddUCScene(Roster.A_P_EntryBoxCode, new AdminProxyEntryBoxCode(this, 60));
            this.AddUCScene(Roster.A_P_FinishWork, new AdminProxyFinishWork(this, 60));
            this.AddUCScene(Roster.A_ControlPanel, new AdministratorControlPanel(this, 360));

            this.SceneTransit(Roster.Home);
            this.timerSceneInfo.Enabled = true;
            this.timerMain.Enabled      = true;

            CLog4net.LogInfo("启动完成");
        }
Exemple #25
0
        public AutorizationFormViewModel()
        {
            ClickSignInCommand   = new RelayCommand(arg => ClickSignInMethod());
            ClickRegisterCommand = new RelayCommand(arg => ClickRegisterMethod());

            var servicesFactory = new ServicesFactory();

            _userService = servicesFactory.GetUserService();
        }
Exemple #26
0
        public CreateProjectFormViewModel()
        {
            AddConnectionCommand = new RelayCommand(arg => AddConnectionMethod());
            CreateProjectCommand = new RelayCommand(arg => CreateProjectMethod());

            var servicesFactory = new ServicesFactory();

            _projectService = servicesFactory.GetProjectService();
        }
        public void ServiceFileWillOverrideServiceInterfacesAutomatically()
        {
            var services = new Dictionary <Type, Type>();

            ServicesFactory.ForEach(
                "Containers\\ReplaceDefaultServiceWithTextFileTests.txt",
                (service, implementation) => { services[service] = implementation; });
            services[typeof(IHostingStarterFactory)].ShouldBe(typeof(CustomStarterFactory));
        }
Exemple #28
0
        private void BindData()
        {
            IPointService service = ServicesFactory.CreatePointService();

            string data = Newtonsoft.Json.JsonConvert.SerializeObject(service.GetListOfPoints(_ageFilters, _genderFilters));

            string myScriptValue = "markers=" + data;

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myScriptName", myScriptValue, true);
        }
        public override Func <Type, object> CreateContainer()
        {
            var kernel = new StandardKernel();

            kernel.Bind <IServiceProvider>().To <NinjectServiceProvider>();
            ServicesFactory.ForEach((service, implementation) => kernel.Bind(service).To(implementation));
            kernel.Bind <IAppLoaderFactory>().To <TestAppLoader1>();
            kernel.Bind <IAppLoaderFactory>().To <TestAppLoader2>();
            return(serviceType => kernel.Get(serviceType));
        }
Exemple #30
0
 public FrmSavaPackage(int seconds, string num, int count) : this()
 {
     ServicesFactory.GetInstance().GetVoicService().BroadcastOnce("您选择的柜子是" + num + "号,请放入包裹并关闭柜门,谢谢!");
     this.labelXInfo.Text = string.Format("<div align='center'>您选择的柜子是<b><font size='+15' color='red'>{0}</font></b>号,还有<font size='+15' color='orange'>{1}</font>次重选机会</div>", num, count);
     //您选的柜门是<b><font size="+15" color="red">11</font></b>号,还有3次重选机会
     this.buttonXCancel.Enabled = true ? count > 0 : false;
     this.seconds            = seconds;
     this.timerMain.Interval = 1000;
     this.timerMain.Enabled  = true;
     this.timerMain.Start();
 }