Example #1
0
        public IEntityBaseRepository <TEntity> GetRepository <TEntity>()
            where TEntity : EntityBase, new()
        {
            //return new NeutrinoRepositoryBase<TEntity>(context);

            return(NinjectHttpContainer.Resolve <IEntityBaseRepository <TEntity> >());
        }
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var validatorEngine = NinjectHttpContainer.Resolve <NHibernateSharedEngineProvider>().GetEngine();

            var parameters = actionContext.ActionDescriptor.GetParameters();
            var arguments  = actionContext.ActionArguments;

            List <InvalidValue>         invalidValues    = new List <InvalidValue>();
            Dictionary <string, object> validationErrors = new Dictionary <string, object>();

            foreach (var p in parameters)
            {
                var validate = p.GetCustomAttributes <Valid>().Count > 0;
                if (!validate)
                {
                    continue;
                }
                var value  = arguments[p.ParameterName];
                var errors = validatorEngine.Validate(value);
                invalidValues.AddRange(errors);
            }

            if (invalidValues.Count > 0)
            {
                foreach (var invalidValue in invalidValues)
                {
                    validationErrors.Add(invalidValue.PropertyName, invalidValue.Message);
                }
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.BadRequest, new ExceptionResponse("Validation exception", Error.VALIDATION_FAILED, validationErrors));
            }
        }
Example #3
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);

            AutoMapperConfig.RegisterMappings();
        }
Example #4
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     NinjectContainer.RegisterModules(NinjectModules.Modules);
     NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);
 }
Example #5
0
        protected void Application_Start()
        {
            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Example #6
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);             // Ninject in Api Versiyonu Burada Ninject ve Ninject.Web.Common projeye nuget tan yuklendi.
 }
Example #7
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            Controllers.RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //ninject registration
            NinjectHttpContainer.RegisterAssembly();
        }
Example #8
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Example #9
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup

            DatabaseConfig.MigrateToLatest();
            AreaRegistration.RegisterAllAreas();

            NinjectHttpContainer.RegisterAssembly();
            NinjectContainer.RegisterAssembly();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Example #10
0
        private void ConfigureOAuth(IAppBuilder app)
        {
            OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/authtoken"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider             = new AuthorizationServerProvider(NinjectHttpContainer.Resolve <IUserManager>()),
                RefreshTokenProvider = new RefreshTokenProvider()
            };

            // Token Generation
            app.UseOAuthAuthorizationServer(OAuthServerOptions);

            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
Example #11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            GlobalConfiguration.Configuration.Filters.Add(new ExceptionHandler());
            GlobalConfiguration.Configuration.Filters.Add(new ExecutionTimeAttribute());

            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);

            //Logger.Instance.Information("Application started");
            _logger.Info("Application started");
        }
Example #12
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);

            if (!System.IO.File.Exists(ConfigurationManager.AppSettings.Get("ServerFilePath")))
            {
                string     path = ConfigurationManager.AppSettings.Get("ServerFilePath");
                FileStream file = File.Create(path);
            }
        }
Example #13
0
        private bool Authorize(Role role, string login, string token)
        {
            IUserCache userCache = NinjectHttpContainer.Resolve <IUserCache>();
            var        auth      = userCache.GetAuthByLogin(login);

            //var cachedToken = userCache.GetTokenByLogin(login);
            //var user = userCache.GetUserByToken(token);
            if (auth == null || auth.GetUser() == null || auth.GetToken() == null || auth.GetToken() != token || auth.GetLogin() != login)
            {
                return(false);
            }
            var ret = auth.GetRole() >= role;

            if (ret)
            {
                AuthenticationUtils.CurrentAuthentication = auth;
            }
            return(ret);
        }
Example #14
0
        public void Configuration(IAppBuilder app)
        {
            NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules);
            ApplicationUserManager.SetDataProtectionProvider(app.GetDataProtectionProvider());

            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(() => new DataAccessContext());
            app.CreatePerOwinContext(() =>
            {
                var context   = new DataAccessContext();
                var userStore = new UserStore <User, Role, Guid, UserLogin, UserRole, Claim>(context);

                return(new ApplicationUserManager(userStore));
            });

            //Authentication configuration
            var authConfig = NinjectHttpContainer.Resolve <AuthenticationConfiguration>();

            authConfig.Config(accessTokenExpireMinutes: 120);
            authConfig.ConfigureAuth(app);

            var config = new HttpConfiguration();

            ////WebApi configuration
            WebApiConfig.Register(config);
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            // NInject config
            app.UseNinjectMiddleware(NinjectHttpContainer.GetKernel);
            app.UseNinjectWebApi(config);

            //Auto Maper
            AutoMapperStartup.Register(NinjectHttpContainer.GetKernel().GetService);

            //Logger
            ApplicationLogger.Logger.Configure();
            config.MessageHandlers.Add(NinjectHttpContainer.Resolve <DelegatingLogFilter>());

            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer       = false;
        }
Example #15
0
 private void ConfigureNinject(IAppBuilder app)
 {
     //Configure Ninject Middleware
     NinjectHttpContainer.RegisterAssembly();
 }
Example #16
0
 public UnitTestBase()
 {
     _kernel = new MoqMockingKernel();
     NinjectHttpContainer.RegisterModules(_kernel, injectModules);
 }