public void Exclude_List_Scope() { var dto = new ExcludeList { Id = 1234, Excludes = new List <Exclude>() { new Exclude { Id = 2345, Key = "Value" }, new Exclude { Id = 3456, Key = "Value" } } }; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] { "ExcludeList.Id", "Exclude.Id" }; Assert.That(dto.ToJson(), Is.EqualTo("{\"Excludes\":[{\"Key\":\"Value\"},{\"Key\":\"Value\"}]}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Excludes:[{Key:Value},{Key:Value}]}")); } }
protected ServiceStackHost(string serviceName, params Assembly[] assembliesWithServices) { this.StartedAt = DateTime.UtcNow; ServiceName = serviceName; AppSettings = new AppSettings(); Container = new Container { DefaultOwner = Owner.External }; ServiceController = CreateServiceController(assembliesWithServices); ContentTypes = Host.ContentTypes.Instance; RestPaths = new List <RestPath>(); Routes = new ServiceRoutes(this); Metadata = new ServiceMetadata(RestPaths); PreRequestFilters = new List <Action <IRequest, IResponse> >(); GlobalRequestFilters = new List <Action <IRequest, IResponse, object> >(); GlobalTypedRequestFilters = new Dictionary <Type, ITypedFilter>(); GlobalResponseFilters = new List <Action <IRequest, IResponse, object> >(); GlobalTypedResponseFilters = new Dictionary <Type, ITypedFilter>(); GlobalMessageRequestFilters = new List <Action <IRequest, IResponse, object> >(); GlobalTypedMessageRequestFilters = new Dictionary <Type, ITypedFilter>(); GlobalMessageResponseFilters = new List <Action <IRequest, IResponse, object> >(); GlobalTypedMessageResponseFilters = new Dictionary <Type, ITypedFilter>(); ViewEngines = new List <IViewEngine>(); ServiceExceptionHandlers = new List <HandleServiceExceptionDelegate>(); UncaughtExceptionHandlers = new List <HandleUncaughtExceptionDelegate>(); AfterInitCallbacks = new List <Action <IAppHost> >(); OnDisposeCallbacks = new List <Action <IAppHost> >(); RawHttpHandlers = new List <Func <IHttpRequest, IHttpHandler> > { HttpHandlerFactory.ReturnRequestInfo, MiniProfilerHandler.MatchesRequest, }; CatchAllHandlers = new List <HttpHandlerResolverDelegate>(); CustomErrorHttpHandlers = new Dictionary <HttpStatusCode, IServiceStackHandler> { { HttpStatusCode.Forbidden, new ForbiddenHttpHandler() }, { HttpStatusCode.NotFound, new NotFoundHttpHandler() }, }; StartUpErrors = new List <ResponseStatus>(); PluginsLoaded = new List <string>(); Plugins = new List <IPlugin> { new HtmlFormat(), new CsvFormat(), new MarkdownFormat(), new PredefinedRoutesFeature(), new MetadataFeature(), new NativeTypesFeature(), }; ExcludeAutoRegisteringServiceTypes = new HashSet <Type> { typeof(AuthenticateService), typeof(RegisterService), typeof(AssignRolesService), typeof(UnAssignRolesService), typeof(NativeTypesService), typeof(PostmanService), }; // force deterministic initialization of static constructor using (JsConfig.BeginScope()) { } }
protected virtual void ProcessOperations(Stream responseStream, IHttpRequest httpReq) { var metadata = EndpointHost.Metadata; var collectionId = Guid.NewGuid().ToString(); var req = GetRequests(httpReq, metadata, collectionId, metadata.Operations) .OrderBy(r => r.Folder) .ThenBy(r => r.Name); var collection = new PostmanCollection { Id = collectionId, Name = EndpointHost.Config.ServiceName, Timestamp = DateTime.UtcNow.ToUnixTimeMs(), Requests = req.ToArray(), Order = new List <string>(), Folders = new List <PostmanFolder>() }; AddToFolders(collection); if (SupportFolders && DoNotAllowFolderIfOnlyOneItem) { MoveOneItemFoldersOneLevelUp(collection); } using (var scope = JsConfig.BeginScope()) { scope.EmitCamelCaseNames = true; JsonSerializer.SerializeToStream(collection, responseStream); } }
public void Can_exclude_properties_scoped() { var dto = new Exclude {Id = 1, Key = "Value"}; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] {"Exclude.Id"}; Assert.That(dto.ToJson(), Is.EqualTo("{\"Key\":\"Value\"}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Key:Value}")); } }
private static void WithinJsonScope(Action action) { using (JsConfigScope config = JsConfig.BeginScope()) { SetJsonConfig(config); action(); } }
public void Can_create_url_with_FieldId() { using (JsConfig.BeginScope()) { JsConfig.IncludePublicFields = true; var url = new FieldId(1).ToUrl("GET"); Assert.That(url, Is.EqualTo("/route/1")); } }
private static JsConfigScope CreateJsConfigThatOverridesDefaultIncludeNullValuesSetting() { var jsConfig = JsConfig.BeginScope(); jsConfig.IncludeNullValues = false; jsConfig.IncludeNullValuesInDictionaries = false; return(jsConfig); }
public ConfigurationScope() { _jsConfigScope = JsConfig.BeginScope(); _jsConfigScope.DateHandler = JsonDateHandler.ISO8601; _jsConfigScope.EmitCamelCaseNames = true; // serialize guids with dashes JsConfig <Guid> .SerializeFn = guid => guid.ToString("D"); }
internal T Deserialize <T>(string content) { using (var scope = JsConfig.BeginScope()) { scope.AlwaysUseUtc = false; scope.AssumeUtc = false; scope.AppendUtcOffset = false; return(JsonSerializer.DeserializeFromString <T>(content)); } }
public static string ToData(IChangeEvent @event) { @event.GuardAgainstNull(nameof(@event)); using (var scope = JsConfig.BeginScope()) { scope.ExcludeTypeInfo = true; return(@event.ToJson()); } }
public string Serialize(object obj) { using (var scope = JsConfig.BeginScope()) { scope.IncludeTypeInfo = false; // ISO8601DateTime: "2019-04-24 20:43:44" // ISO8601DateOnly: "2018-12-12" // ISO8601: "2018-12-12T00:00:00.0000000" scope.DateHandler = DateHandler.ISO8601; return(JsonSerializer.SerializeToString(obj)); } }
public void Public_readonly_fields_can_be_deserialized() { using (JsConfig.BeginScope()) { JsConfig.IncludePublicFields = true; var instance = new TypeWithPublicFields("Hello"); var deserilized = instance.ToJson(); var copy = deserilized.FromJson <TypeWithPublicFields>(); Assert.That(copy.Text, Is.EqualTo(instance.Text)); } }
private static void SetLimitHeaders(IResponse response, RateLimitResult result) { var headerResults = RateLimitHeader.Create(result?.Results); using (var config = JsConfig.BeginScope()) { config.ExcludeTypeInfo = true; foreach (var header in headerResults) { response.AddHeader(header.HeaderName, header.Limits.ToJson()); } } }
/// <summary> /// Saves the specified recipient macros for the specified bulk email. /// </summary> /// <param name="bulkEmailId">The bulk email identifier.</param> /// <param name="recipientMacrosCollection">The recipient macros collection.</param> public virtual void Save(Guid bulkEmailId, Dictionary <Guid, IEnumerable <BulkEmailMacroInfo> > recipientMacrosCollection) { var parametersPerInsertRow = 4; var chunksCount = CalculateChunks(recipientMacrosCollection.Count, parametersPerInsertRow); JsConfig.ExcludeTypeInfo = true; using (var scope = JsConfig.BeginScope()) { scope.ExcludeTypeInfo = true; var macrosBatches = recipientMacrosCollection .Select(x => new KeyValuePair <Guid, string>(x.Key, x.Value.ToJson())).SplitOnParts(chunksCount); InsertMacrosBatches(bulkEmailId, macrosBatches); } }
public Task <IRestResponse> PostAsync(SlackMessage slackMessage) { var request = new RestRequest(_webhookUri.PathAndQuery, Method.POST); using (var scope = JsConfig.BeginScope()) { scope.EmitLowercaseUnderscoreNames = true; scope.IncludeNullValues = false; SetPropertyConvention(scope); request.AddParameter("payload", JsonSerializer.SerializeToString(slackMessage)); } return(ExecuteTaskAsync(request)); }
/// <summary> /// Registers service health checks with consul /// </summary> /// <param name="healthChecks">the health checks to register</param> /// <exception cref="GatewayServiceDiscoveryException">throws exception if unable to register health checks</exception> public static void RegisterHealthChecks(params ServiceHealthCheck[] healthChecks) { var logger = LogManager.GetLogger(typeof(ConsulClient)); foreach (var check in healthChecks) { try { var consulCheck = new ConsulRegisterCheck(check.Id, check.ServiceId) { HTTP = check.Http, TCP = check.Tcp, IntervalInSeconds = check.IntervalInSeconds, Notes = check.Notes, DeregisterCriticalServiceAfterInMinutes = check.DeregisterCriticalServiceAfterInMinutes }; HealthcheckValidator.ValidateAndThrow(consulCheck); using (var config = JsConfig.BeginScope()) { config.EmitCamelCaseNames = false; config.IncludeNullValues = false; ConsulFeature.ConsulAgentResolver.CombineWith(consulCheck.ToPutUrl()).PutJsonToUrl( consulCheck, null, response => { if (response.IsErrorResponse()) { logger.Error( $"Could not register health check ${check.Id} with Consul. {response.StatusDescription}"); } else { logger.Info( $"Registered health check with Consul `{check.Id}`"); } }); } } catch (Exception ex) { logger.Error("Failed to register health check", ex); throw new GatewayServiceDiscoveryException($"Could not register service health check {check.Id}", ex); } } }
public void Respects_EmitDefaultValue() { using (var x = JsConfig.BeginScope()) { x.IncludeNullValues = true; var jsonModel = new Movie { Genres = null }; var ssJson = JsonSerializer.SerializeToString(jsonModel); var wcfJson = BclJsonDataContractSerializer.Instance.Parse(jsonModel); Assert.That(ssJson, Is.EqualTo(wcfJson)); } }
public RollbarRequestLogger(RollbarLoggerPlugin plugin) { _plugin = plugin; // The request message MUST be serialized to omit NULL TraceChain and other properties. // We enforce the custom configuration here, so that regardless of what AppHost setting we have, // the logger will use the appropriate serialization strategy JsConfig <RollbarLogRequest> .RawSerializeFn = (obj) => { using (var config = JsConfig.BeginScope()) { config.EmitCamelCaseNames = true; config.IncludeNullValues = false; return(obj.ToJson()); } }; }
public void Does_serialize_to_UnixTime_when_scoped() { var dto = new TestObject { Date = new DateTime(2001, 01, 01, 0, 0, 0, DateTimeKind.Utc) }; using (var config = JsConfig.BeginScope()) { config.DateHandler = DateHandler.UnixTime; var json = dto.ToJson(); Assert.That(json, Is.EquivalentTo("{\"Date\":978307200}")); var fromJson = JsonSerializer.DeserializeFromString <TestObject>(json); Assert.That(fromJson.Date, Is.EqualTo(dto.Date)); } }
public void Can_include_nested_only() { var dto = new IncludeExclude { Id = 1234, Name = "TEST", Obj = new Exclude { Id = 1, Key = "Value" } }; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] { "Exclude.Id", "IncludeExclude.Id", "IncludeExclude.Name" }; Assert.That(dto.ToJson(), Is.EqualTo("{\"Obj\":{\"Key\":\"Value\"}}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Obj:{Key:Value}}")); } Assert.That(JsConfig.ExcludePropertyReferences, Is.EqualTo(null)); }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> public override void Configure(Container container) { container.Register(_ => new ClientListing()); //container.Register(_ => new ClientListing { //new EntityClient("Evelio", "Gil"){Zip = 34786}, //new EntityClient("Fernand", "Gil"), //new EntityClient("Veronica", "Sofia"){Address = "Windermere"}, //new EntityClient("Gabriela", "Gil"){Country = "USA"} //}); using (JsConfig.BeginScope()) { JsConfig.DateHandler = DateHandler.ISO8601; ; // some JSON serialization code } }
public Task <InputFormatterResult> ReadAsync(InputFormatterContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var request = context.HttpContext.Request; var reader = context.ReaderFactory(request.Body, Encoding.UTF8); var scope = JsConfig.BeginScope(); scope.DateHandler = DateHandler.ISO8601; var result = JsonSerializer.DeserializeFromReader(reader, context.ModelType); scope.Dispose(); reader.Dispose(); return(InputFormatterResult.SuccessAsync(result)); }
private static JsConfigScope BeginJsConfigScope() { var config = JsConfig.BeginScope(); config.ExcludeTypeInfo = true; config.DateHandler = DateHandler.ISO8601; config.AlwaysUseUtc = true; config.AssumeUtc = true; config.ConvertObjectTypesIntoStringDictionary = true; config.TryToParseNumericType = true; config.ParsePrimitiveFloatingPointTypes = ParseAsType.Single; config.ParsePrimitiveIntegerTypes = ParseAsType.Int32 | ParseAsType.Int64; config.IncludeNullValues = true; JsConfig <DateTime> .SerializeFn = SerializeDateTime; JsConfig <DateTime?> .SerializeFn = SerializeDateTime; JsConfig <DateTime> .DeSerializeFn = DeserializeDateTime; JsConfig <DateTime?> .DeSerializeFn = DeserializeDateTimeNullable; return(config); }
private void ProcessNonStreamRequest(IHttpRequest httpReq, IHttpResponse httpRes) { try { var response = GetHystrixCommandInfo(httpReq.ServicePath); using (var jsConfigScope = JsConfig.BeginScope()) { jsConfigScope.EmitCamelCaseNames = true; var json = JsonSerializer.SerializeToString(response); httpRes.ContentType = ContentType.Json; httpRes.Write(json); } } catch { } finally { httpRes.Close(); } }
/// <summary> /// Posts data to the specified method. /// </summary> /// <typeparam name="T">Response output type.</typeparam> /// <param name="methodName">Name of the service method.</param> /// <param name="requestBody">The request body.</param> /// <param name="timeoutSec">The timeout sec.</param> /// <returns>Response's output.</returns> protected T Post <T>(string methodName, object requestBody, int timeoutSec) { T response; try { using (var scope = JsConfig.BeginScope()) { scope.DateHandler = JsonDateHandler.ISO8601; _serviceClient.Timeout = TimeSpan.FromSeconds(timeoutSec); response = _serviceClient.Post <T>(methodName, requestBody); } } catch (WebServiceException ex) { switch (ex.StatusCode) { case (int)HttpStatusCode.Unauthorized: throw new IncorrectConfigurationException(CloudServicesApiKey, _apiKey); case (int)HttpStatusCode.NotFound: throw new IncorrectConfigurationException("Service method", methodName, "Service method not found"); case (int)HttpStatusCode.Forbidden: throw new Exception(ex.ErrorMessage, ex); case (int)HttpStatusCode.InternalServerError: string message = $"[{HttpStatusCode.InternalServerError}] {ex.ResponseStatus?.Message}"; Log.Error(message, ex); throw new HttpException(ex.StatusCode, message, ex); case (int)HttpStatusCode.BadRequest: string errorMessage = $"[{HttpStatusCode.BadRequest}] methodName: " + $"{methodName} {ex.ResponseDto?.SerializeAndFormat()}"; Log.Error(errorMessage); throw new HttpException(ex.StatusCode, errorMessage, ex); default: throw; } } catch (WebException ex) { Log.ErrorFormat(WebExceptionMessage, methodName, ex.Status, ex.Message); throw; } return(response); }
/// <summary> /// Registers the servicestack apphost with the local consul agent /// </summary> /// <exception cref="GatewayServiceDiscoveryException">throws exception if registration was not successful</exception> public static void RegisterService(ServiceRegistration registration) { var consulServiceRegistration = new ConsulServiceRegistration(registration.Id, registration.Name) { Address = registration.Address, Tags = registration.Tags, Port = registration.Port }; ServiceValidator.ValidateAndThrow(consulServiceRegistration); var registrationUrl = ConsulFeature.ConsulAgentResolver.CombineWith(consulServiceRegistration.ToPutUrl()); using (var config = JsConfig.BeginScope()) { config.EmitCamelCaseNames = false; config.IncludeNullValues = false; registrationUrl.PutJsonToUrl(consulServiceRegistration, null, response => { var logger = LogManager.GetLogger(typeof(ConsulClient)); if (response.StatusCode.IsErrorResponse()) { logger.Fatal( $"Could not register appHost with Consul. It will not be discoverable: {consulServiceRegistration}"); throw new GatewayServiceDiscoveryException( "Failed to register service with consul"); } else { logger.Info( $"Registered service with Consul {consulServiceRegistration}"); AppDomain.CurrentDomain.ProcessExit += (sender, args) => UnregisterService(consulServiceRegistration.ID); AppDomain.CurrentDomain.UnhandledException += (sender, args) => UnregisterService(consulServiceRegistration.ID); } }); } }
public void Exclude_all_nested() { var dto = new IncludeExclude { Id = 1234, Name = "TEST", Obj = new Exclude { Id = 1, Key = "Value" } }; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] { "Exclude.Id", "Exclude.Key" }; Assert.AreEqual(2, config.ExcludePropertyReferences.Length); var actual = dto.ToJson(); Assert.That(actual, Is.EqualTo("{\"Id\":1234,\"Name\":\"TEST\",\"Obj\":{}}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Id:1234,Name:TEST,Obj:{}}")); } }
public virtual bool Post(SlackMessage slackMessage) { var request = new RestRequest(_webhookUri.PathAndQuery, Method.POST); using (var scope = JsConfig.BeginScope()) { scope.EmitLowercaseUnderscoreNames = true; scope.IncludeNullValues = false; SetPropertyConvention(scope); request.AddParameter("payload", JsonSerializer.SerializeToString(slackMessage)); try { var response = _restClient.Execute(request); return(response.StatusCode == HttpStatusCode.OK && response.Content == POST_SUCCESS); } catch (Exception) { return(false); } } }
private void ProcessStreamRequest(IHttpRequest httpReq, IHttpResponse httpRes) { try { httpRes.AddHeader("Content-Type", "text/event-stream;charset=UTF-8"); httpRes.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate"); httpRes.AddHeader("Pragma", "no-cache"); // CORS support httpRes.AddHeader("Access-Control-Allow-Origin", "*"); httpRes.AddHeader("Access-Control-Allow-Methods", "GET, POST"); httpRes.AddHeader("Access-Control-Allow-Headers", "Content-Type"); var sendInterval = this.GetSendInterval(httpReq); var results = GetHystrixCommandInfo(httpReq.ServicePath); httpRes.Write(string.Format("retry: {0}\n", sendInterval)); using (var jsConfigScope = JsConfig.BeginScope()) { jsConfigScope.EmitCamelCaseNames = true; foreach (var hystrixCommand in results) { var json = JsonSerializer.SerializeToString(hystrixCommand); httpRes.Write(string.Format("data: {0}\n\n", json)); } httpRes.Flush(); } } catch { } finally { httpRes.Close(); } }
public void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName) { if (EndpointHost.ApplyPreRequestFilters(httpReq, httpRes)) { return; } List <KeyValuePair <string, object> > configInfo = new List <KeyValuePair <string, object> >(); if (AppHostBase.Instance != null) { configInfo.Add(new KeyValuePair <string, object>("StartUpTime", AppHostBase.Instance.StartUpTime)); } if (AppHostHttpListenerBase.Instance != null) { configInfo.Add(new KeyValuePair <string, object>("StartUpTime", AppHostHttpListenerBase.Instance.StartUpTime)); } configInfo.Add(new KeyValuePair <string, object>("AppId", ServiceUtils.AppId)); configInfo.Add(new KeyValuePair <string, object>("IPv4", ServiceUtils.HostIP)); configInfo.Add(new KeyValuePair <string, object>("MachineName", ServiceUtils.MachineName)); configInfo.Add(new KeyValuePair <string, object>("SOA.CurrentEnv", EnvironmentUtility.CurrentEnv)); var metadata = EndpointHost.MetadataMap[httpReq.ServicePath]; configInfo.Add(new KeyValuePair <string, object>("SOA.ServiceName", metadata.ServiceName)); configInfo.Add(new KeyValuePair <string, object>("SOA.ServiceNamespace", metadata.ServiceNamespace)); configInfo.Add(new KeyValuePair <string, object>("SOA.ServiceTestSubEnv", metadata.ServiceTestSubEnv ?? "null")); configInfo.Add(new KeyValuePair <string, object>( ServiceMetadata.DefaultLogErrorWithRequestInfoSettingKey, metadata.LogErrorWithRequestInfo)); configInfo.Add(new KeyValuePair <string, object>( ServiceMetadata.DefaultLogCommonRequestInfoSettingKey, metadata.LogCommonRequestInfo)); configInfo.Add(new KeyValuePair <string, object>( ServiceMetadata.DefaultLogH5HeadExtensionDataSettingKey, metadata.LogH5HeadExtensionData)); bool circuitBreakerForceClosed = metadata.CircuitBreakerForceClosed; configInfo.Add(new KeyValuePair <string, object>(ServiceMetadata.DefaultCircuitBreakerForceClosedSettingKey, circuitBreakerForceClosed)); Dictionary <string, double> timeoutMap = new Dictionary <string, double>(); foreach (Operation operation in metadata.Operations) { timeoutMap.Add(operation.Name, operation.HystrixCommand.GetExecutionTimeout().TotalMilliseconds); } configInfo.Add(new KeyValuePair <string, object>(ServiceMetadata.DefaultOperationTimeoutMapSettingKey, timeoutMap)); configInfo.Add(new KeyValuePair <string, object>( ServiceMetadata.DefaultUseChunkedTransferEncodingSettingKey, metadata.UseChunkedTransferEncoding)); configInfo.Add(new KeyValuePair <string, object>("SOA.FxConfigWebServiceUtils.Enabled", AntFxConfigWebServiceUtils.Enabled)); configInfo.Add(new KeyValuePair <string, object>("SOA.FxConfigWebServiceUtils.ApiUrl", AntFxConfigWebServiceUtils.ConfigWebServiceApiUrl)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MinGlobalDefaultTimeout", HystrixCommandHelper.MinGlobalDefaultCircuitBreakerTimeoutSetting.TotalMilliseconds.ToString())); configInfo.Add(new KeyValuePair <string, object>( "SOA.GlobalDefaultTimeout", HystrixCommandHelper.GlobalDefaultCircuitBreakerTimeoutSetting.HasValue ? HystrixCommandHelper.GlobalDefaultCircuitBreakerTimeoutSetting.Value.TotalMilliseconds.ToString() : null)); configInfo.Add(new KeyValuePair <string, object>( "SOA.FrameworkDefaultTimeout", HystrixPropertiesCommandDefault.DefaultExecutionIsolationThreadTimeout.TotalMilliseconds.ToString())); configInfo.Add(new KeyValuePair <string, object>( "SOA.FrameworkDefaultConnectionMaxRequestCount", ServiceMetadata.FrameworkDefaultConnectionMaxRequestCount)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MinConnectionMaxRequestCount", ServiceMetadata.MinConnectionMaxRequestCount)); configInfo.Add(new KeyValuePair <string, object>( "SOA.CheckConnectionMaxRequestCount", metadata.CheckConnectionMaxRequestCount)); configInfo.Add(new KeyValuePair <string, object>( "SOA.ConnectionMaxRequestCount", metadata.ConnectionMaxRequestCount)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.RequestLogMaxSize", MessageLogConfig.RequestLogMaxSize)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.ResponseLogMaxSize", MessageLogConfig.ResponseLogMaxSize)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.FrameworkDefalut.Test", MessageLogConfig.FrameworkDefalutMessageLogConfigOfTestEnv)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.FrameworkDefalut.Uat", MessageLogConfig.FrameworkDefalutMessageLogConfigOfUatEnv)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.FrameworkDefalut.Prod", MessageLogConfig.FrameworkDefalutMessageLogConfigOfProdEnv)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.FrameworkDefalut.Null", MessageLogConfig.FrameworkDefalutMessageLogConfigOfNullEnv)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.FrameworkDefault.Current", MessageLogConfig.CurrentFrameworkDefaultMessageLogConfig)); configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.Service", metadata.ServiceMessageLogConfig)); var operationMessageConfigs = from operation in metadata.Operations select new { operation.Name, operation.OperationMessageLogConfig, }; configInfo.Add(new KeyValuePair <string, object>( "SOA.MessageLogConfig.Operation", operationMessageConfigs)); configInfo.Add(new KeyValuePair <string, object>( "SOA.DeserializeRequestUseMemoryStream", metadata.DeserializeRequestUseMemoryStream)); configInfo.Add(new KeyValuePair <string, object>( "SOA.LogPopulateExceptionAsWarning", ReflectionUtils.LogPopulateExceptionAsWarning)); foreach (IHasConfigInfo configInfoOwner in ConfigInfoOwners) { configInfo.AddRange(configInfoOwner.GetConfigInfo(httpReq.ServicePath)); } using (JsConfigScope scope = JsConfig.BeginScope()) { scope.ExcludeTypeInfo = true; scope.DateHandler = JsonDateHandler.LongDateTime; httpRes.ContentType = "application/json"; httpRes.Write(WrappedJsonSerializer.Instance.SerializeToString(configInfo)); } }