Exemplo n.º 1
0
        /// <summary>Assert test configuration.</summary>
        ///
        /// <param name="assemblies">A variable-length parameters list containing assemblies.</param>
        public static void AssertTestConfig(params Assembly[] assemblies)
        {
            if (Config != null)
            {
                return;
            }

            var config = EndpointHostConfig.Instance;

            config.ServiceName    = "Test Services";
            config.ServiceManager = new ServiceManager(assemblies.Length == 0 ? new[] { Assembly.GetCallingAssembly() } : assemblies);
            Config = config;
        }
Exemplo n.º 2
0
        /// <summary>Sets a configuration.</summary>
        ///
        /// <param name="config">The configuration.</param>
        public void SetConfig(EndpointHostConfig config)
        {
            if (config.ServiceName == null)
            {
                config.ServiceName = EndpointHostConfig.Instance.ServiceName;
            }

            if (config.ServiceManager == null)
            {
                config.ServiceManager = EndpointHostConfig.Instance.ServiceManager;
            }

            config.ServiceManager.ServiceController.EnableAccessRestrictions = config.EnableAccessRestrictions;

            EndpointHost.Config = config;
        }
Exemplo n.º 3
0
        private static void Reset()
        {
            ContentTypeFilter = HttpResponseFilter.Instance;
            RawRequestFilters = new List <Action <IHttpRequest, IHttpResponse> >();
            RequestFilters    = new List <Action <IHttpRequest, IHttpResponse, object> >();
            ResponseFilters   = new List <Action <IHttpRequest, IHttpResponse, object> >();
            ViewEngines       = new List <IViewEngine>();
            CatchAllHandlers  = new List <HttpHandlerResolverDelegate>();
            Plugins           = new List <IPlugin> {
                new HtmlFormat(),
                new CsvFormat(),
                new MarkdownFormat(),
                new PredefinedRoutesFeature(),
                new MetadataFeature(),
            };

            //Default Config for projects that want to use components but not WebFramework (e.g. MVC)
            Config = new EndpointHostConfig(
                "Empty Config",
                new ServiceManager(new Container(), new ServiceController(null)));
        }