Exemplo n.º 1
0
        private void ConfigureOAuth(IAppBuilder app)
        {
            var authorizationProvider = NinjectConfiguration.GetInstance().Kernel.GetService <SimpleAuthorizationServerProvider>();
            var refreshTokenProvider  = NinjectConfiguration.GetInstance().Kernel.GetService <SimpleRefreshTokenProvider>();

            var OAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(20),
                Provider             = authorizationProvider,
                RefreshTokenProvider = refreshTokenProvider
            };

            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            NinjectConfiguration.Configure();

            var kernel = NinjectConfiguration.GetInstance().Kernel;

            DbInitializer.Initialize(kernel.Get <IDbContext>()).Wait();

            var inputGpio    = kernel.Get <IGpioInputInterface>();
            var inputManager = kernel.Get <IInputCircuitsManager>();

            inputGpio.CircuitStateChanged = inputManager.HandleCircuitChange;

            LogHelper.LogMessage("Input GPIO: " + baseAddress);

            using (WebApp.Start <WebApiStartup>(url: baseAddress))
            {
                LogHelper.LogMessage("Host started on: " + baseAddress);
#if DEBUG
                while (true)
                {
                    var message = Console.ReadLine();
                    if (!string.IsNullOrEmpty(message))
                    {
                        var arguments = message.Split(':');
                        if (arguments.Count() == 2)
                        {
                            InputPin inputPin;
                            bool     state;

                            var pinParsedSucessfull   = Enum.TryParse(arguments[0], out inputPin);
                            var stateParsedSucessfull = Boolean.TryParse(arguments[1], out state);

                            if (pinParsedSucessfull && stateParsedSucessfull)
                            {
                                inputGpio.CircuitStateChanged(state, inputPin);
                            }
                        }
                    }
                }
#else
                Console.ReadLine();
#endif
            }
        }