public static void Initialize( HttpConfiguration config, IApiContainer container = null, IDomainServiceResolver domainServiceResolver = null, Action <HttpConfiguration> postConfigure = null, bool initializeHelpPage = true) // TODO: refactor to instance BootStrapper class and make InitializeDocumentationApplication() public; pass all parameter in a constructor or factory { if (config == null) { throw new ArgumentNullException("config"); } var hconfig = SetConfiguration(config, postConfigure); container = container ?? CreateContainer(config, domainServiceResolver); container.RegisterDependencies(); SetupDependencyResolver(config, container); ConfigureFormatters(config, container); ConfigureMessageHandlers(config.MessageHandlers, container); ConfigureFilters(config.Filters, container); container.Resolve <IWebApiConfigurator>() .Configure(config, hconfig); if (initializeHelpPage) { InitializeDocumentationApplication(config, container); } }
static void ConfigureFormatters(HttpConfiguration config, IApiContainer container) { // Remove all the default formatters config.Formatters.Clear(); // Add all the formatters resolved by the container container.ResolveMediaTypeFormatters().Apply(config.Formatters.Add); //// Add the custom formatters //config.Formatters.Add(container.ResolveMediaTypeFormatter<HalJsonMediaTypeFormatter>()); }
public BasicApiProvider(IApiContainer container) { // simplified logic here doesn't scan for possible Apis; just adds what it knows is implemented by the PluginApi // this removes the possibility of automagically picking up a Api in a nested class, (find the type, then // find the field), but we're going to keep such logic out of the basic provider. Anything the passed // container doesn't implement directly needs to be added with Register() // this also fully allows apis that are not IExternalApi var libs = container.Libraries; _Apis = libs; }
static void InitializeDocumentationApplication(HttpConfiguration config, IApiContainer container) { const string apiName = "MyBeerTap API documentation"; // initialize help documentation module ApiDocumentationApplication.Initialize( container, config, new ApiDocumentationConfiguration( container.ResourceAssembly, typeof(HelpController).Assembly, () => apiName) ); }
public MgmtServiceApiClient(IApiContainer apiContainer) { _apiContainer = apiContainer; }
static void SetupDependencyResolver(HttpConfiguration config, IApiContainer container) { // REST Api resolver config.DependencyResolver = container; }
static void ConfigureFilters(HttpFilterCollection filters, IApiContainer container) { container .ResolveExceptionFilters() .Apply(filters.Add); }
static void ConfigureMessageHandlers(ICollection <DelegatingHandler> messageHandlers, IApiContainer container) { // TODO: Add handlers for implementing security // NOTE: The message handlers included in this template are RQ specific // and may need to be altered to meet the security requirements of a new API. container.ResolveMessageHandlers().Apply(messageHandlers.Add); }
public virtual void Init(IApiContainer api) { _api = api; Running = true; }
public BasicApiProvider(IApiContainer apiContainer) => _libs = apiContainer.Libraries;