コード例 #1
0
        public override void Configure(Funq.Container container)
        {
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            // Remove some unused features that by default are included
            Plugins.RemoveAll(p => p is CsvFormat);
            Plugins.RemoveAll(p => p is MetadataFeature);

            // Get disable features specified in Config file (i.e. Soap, Metadata, etc.)
            var disabled = AppHostConfigHelper.GetDisabledFeatures();

            // Construct Service Endpoint Host Configuration store
            var config = new EndpointHostConfig
            {
                DefaultContentType = ContentType.Json,
                WriteErrorsToResponse = false,
                EnableFeatures = Feature.All.Remove(disabled),
                AppendUtf8CharsetOnContentTypes = new HashSet<string> { ContentType.Html },
            };

            // Apply configuration
            SetConfig(config);

            // Initialize Databases & associated Routes
            container.InitDatabaseRoutes(Routes);

            // Register Cache Clients
            container.Register<ICacheClient>(new MemoryCacheClient());

            // Register Redis Client Manager
            container.Register<IRedisClientsManager>(c =>
                new PooledRedisClientManager("localhost:6379"));
        }