Esempio n. 1
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.ApplicationExit += Token.ApplicationExit;
            Application.SetCompatibleTextRenderingDefault(false);
            MefBootstrapper.ComposeParts();
            var creationService = new DataCreationService();

            creationService.CreateData();

            var apiHost  = LocalSettings.ApiHost;
            var apiPort  = LocalSettings.ApiPort;
            var httpHost = string.Format("http://{0}:{1}", apiHost, apiPort);

            var config = new HttpSelfHostConfiguration(httpHost);

            //GET =>  http://localhost:8080/api/getToken/{pin}
            config.Routes.MapHttpRoute("LoginRoute", "api/getToken/{pin}", new
            {
                controller = "Login"
            });
            //GET =>  http://localhost:8080/api/{token}/{controller}/{id}
            config.Routes.MapHttpRoute("API Default", "api/{token}/{controller}/{id}",
                                       new
            {
                id = RouteParameter.Optional
            });

            using (var server = new HttpSelfHostServer(config))
            {
                server.Configuration.DependencyResolver = new MefDependencyResolver(MefBootstrapper.Container);
                server.OpenAsync().Wait();

                if (LocalSettings.TokenLifeTime.Ticks > 0)
                {
                    var tokenGarbageTimer = new Timer
                    {
                        Interval = (int)new TimeSpan(0, 1, 0).TotalMilliseconds
                    };
                    tokenGarbageTimer.Tick += Token.CollectGarbage;
                    tokenGarbageTimer.Start();
                }
                Application.Run(new FrmMain());
            }
        }
Esempio n. 2
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MefBootstrapper.ComposeParts();
            var creationService = new DataCreationService();

            creationService.CreateData();

            var config = new HttpSelfHostConfiguration("http://localhost:8080");

            config.Routes.MapHttpRoute(
                "API Default", "api/{controller}/{id}",
                new { id = RouteParameter.Optional });

            using (var server = new HttpSelfHostServer(config))
            {
                server.Configuration.DependencyResolver = new MefDependencyResolver(MefBootstrapper.Container);
                server.OpenAsync().Wait();
                Application.Run(new FrmMain());
            }
        }