/// <summary> /// Loads the module into the kernel. /// </summary> public override void Load() { var configuration = RestifyConfigurationSection.GetXmlConfiguration(); this.Bind <IRestMethodExtractor>().To <AttributeBasedRestMethodExtractor>().InSingletonScope(); this.Bind <IRequestHeaderFactory>().To <RequestHeaderFactory>().InSingletonScope(); this.Bind <IUrlPathBuilder>().To <UrlPathBuilder>().InSingletonScope(); this.Bind <IRequestHeaderCollector>().To <DefaultRequestHeaderCollector>().InSingletonScope(); this.Bind <IRequestHeaderCollector>().To <FixedRequestHeaderCollector>().InSingletonScope(); this.Bind <IRequestHeaderCollector>().To <MappedHeaderCollector>().InSingletonScope(); this.Bind <IRequestHeaderCollector>().To <AuthorizingHeaderCollector>(); this.Bind <IResponseHeaderMapper>().To <ResponseHeaderMapper>().InSingletonScope(); this.Bind <IRestifyConfiguration>().ToConstant(configuration).InSingletonScope(); this.Bind <IHttpRequestMessageFactory>().To <HttpRequestMessageFactory>().InSingletonScope(); this.Bind <IAuthorizationStore>().To <FileSystemAuthorizationStore>(); this.Bind <IRequestExecutionStrategy>().To <DefaultRequestExecutionStrategy>(); this.Bind <IAuthorizationContext>().To <AuthorizationContext>(); this.Bind <IRequestProcessor>().To <RequestProcessor>(); this.Bind <IAuthorizationHandler>().To <NullAuthorizationHandler>(); var authorizationContextConfiguration = configuration.GetAuthorizationContextConfiguration(this.authorizationContextName); this.Bind <IAuthorizationContextConfiguration>().ToConstant(authorizationContextConfiguration).InSingletonScope(); this.Bind <IAuthorizationConfiguration>().ToConstant(authorizationContextConfiguration.Authorization).InSingletonScope(); //this.Bind<ILog>().ToMethod(m => LogManager.GetLogger("Default")).InSingletonScope(); }
/// <summary> /// Initializes static members of the <see cref="AuthorizationContextProvider"/> class. /// </summary> /// <exception cref="ArgumentNullException">The value of '<paramref name="additionalModules"/>' cannot be null. </exception> public AuthorizationContextProvider([NotNull] params INinjectModule[] additionalModules) { if (additionalModules == null) { throw new ArgumentNullException(nameof(additionalModules)); } foreach (var authorizationContextConfiguration in RestifyConfigurationSection.GetXmlConfiguration().AuthorizationContextConfigurations) { var authorizationContextKernel = new StandardKernel(new QueryfyDotNetRegistrations(), new ServiceInitialization(authorizationContextConfiguration.Name)); authorizationContextKernel.Load(additionalModules); this.authorizationContextKernels.Add(authorizationContextConfiguration.Name, authorizationContextKernel); } }