internal JsConfigScope() { PclExport.Instance.BeginThreadAffinity(); parent = head; head = this; }
internal JsConfigScope() { PclExport.Instance.BeginThreadAffinity(); this.parent = Current; Current = this; }
internal JsConfigScope() { #if !SILVERLIGHT Thread.BeginThreadAffinity(); #endif parent = head; head = this; }
public void Dispose() { if (!disposed) { disposed = true; head = parent; PclExport.Instance.EndThreadAffinity(); } }
public void Dispose() { if (!this.disposed) { this.disposed = true; Current = this.parent; PclExport.Instance.EndThreadAffinity(); } }
public ConfigScope() { jsConfigScope = JsConfig.With(dateHandler: DateHandler.UnixTime, propertyConvention: PropertyConvention.Lenient, emitLowercaseUnderscoreNames: true, emitCamelCaseNames: false); holdQsStrategy = QueryStringSerializer.ComplexTypeStrategy; QueryStringSerializer.ComplexTypeStrategy = QueryStringStrategy.FormUrlEncoded; }
internal JsConfigScope() { PclExport.Instance.BeginThreadAffinity(); #if NETCORE parent = head.Value; head.Value = this; #else parent = head; head = this; #endif }
public void Dispose() { if (!disposed) { disposed = true; Debug.Assert(this == head, "Disposed out of order."); head = parent; PclExport.Instance.EndThreadAffinity(); } }
private void SetPropertyConvention(JsConfigScope scope) { var assembly = Assembly.GetAssembly(typeof(JsConfig)); var jsConfig = assembly.GetType("ServiceStack.Text.JsConfig"); var conventionEnum = assembly.GetType("ServiceStack.Text.JsonPropertyConvention") ?? assembly.GetType("ServiceStack.Text.PropertyConvention"); var propertyConvention = jsConfig.GetProperty("PropertyConvention"); var lenient = conventionEnum.GetField("Lenient"); var enumValue = Enum.ToObject(conventionEnum, (int) lenient.GetValue(conventionEnum)); propertyConvention.SetValue(scope, enumValue, null); }
public void Dispose() { if (!disposed) { disposed = true; Debug.Assert(this == head, "Disposed out of order."); head = parent; #if !SILVERLIGHT Thread.EndThreadAffinity(); #endif } }
public static JsConfigScope CreateScope(string config, JsConfigScope scope = null) { if (string.IsNullOrEmpty(config)) { return(scope); } if (scope == null) { scope = BeginScope(); } var items = config.Split(','); foreach (var item in items) { var parts = item.SplitOnFirst(':'); var key = parts[0].ToLower(); var value = parts.Length == 2 ? parts[1].ToLower() : null; var boolValue = parts.Length == 1 || (value != "false" && value != "0"); switch (key) { case "cotisd": case "convertobjecttypesintostringdictionary": scope.ConvertObjectTypesIntoStringDictionary = boolValue; break; case "ttpptv": case "trytoparseprimitivetypevalues": scope.TryToParsePrimitiveTypeValues = boolValue; break; case "ttpnt": case "trytoparsenumerictype": scope.TryToParseNumericType = boolValue; break; case "edv": case "excludedefaultvalues": scope.ExcludeDefaultValues = boolValue; break; case "inv": case "includenullvalues": scope.IncludeNullValues = boolValue; break; case "invid": case "includenullvaluesindictionaries": scope.IncludeNullValuesInDictionaries = boolValue; break; case "ide": case "includedefaultenums": scope.IncludeDefaultEnums = boolValue; break; case "eti": case "excludetypeinfo": scope.ExcludeTypeInfo = boolValue; break; case "iti": case "includetypeinfo": scope.IncludeTypeInfo = boolValue; break; case "eccn": case "emitcamelcasenames": scope.TextCase = boolValue ? TextCase.CamelCase : scope.TextCase; break; case "elun": case "emitlowercaseunderscorenames": scope.TextCase = boolValue ? TextCase.SnakeCase : scope.TextCase; break; case "pi": case "preferinterfaces": scope.PreferInterfaces = boolValue; break; case "tode": case "throwondeserializationerror": case "toe": case "throwonerror": scope.ThrowOnError = boolValue; break; case "teai": case "treatenumasinteger": scope.TreatEnumAsInteger = boolValue; break; case "sdtc": case "skipdatetimeconversion": scope.SkipDateTimeConversion = boolValue; break; case "auu": case "alwaysuseutc": scope.AlwaysUseUtc = boolValue; break; case "au": case "assumeutc": scope.AssumeUtc = boolValue; break; case "auo": case "appendutcoffset": scope.AppendUtcOffset = boolValue; break; case "ipf": case "includepublicfields": scope.IncludePublicFields = boolValue; break; case "dh": case "datehandler": switch (value) { case "timestampoffset": case "to": scope.DateHandler = DateHandler.TimestampOffset; break; case "dcjsc": case "dcjscompatible": scope.DateHandler = DateHandler.DCJSCompatible; break; case "iso8601": scope.DateHandler = DateHandler.ISO8601; break; case "iso8601do": case "iso8601dateonly": scope.DateHandler = DateHandler.ISO8601DateOnly; break; case "iso8601dt": case "iso8601datetime": scope.DateHandler = DateHandler.ISO8601DateTime; break; case "rfc1123": scope.DateHandler = DateHandler.RFC1123; break; case "ut": case "unixtime": scope.DateHandler = DateHandler.UnixTime; break; case "utm": case "unixtimems": scope.DateHandler = DateHandler.UnixTimeMs; break; } break; case "tsh": case "timespanhandler": switch (value) { case "df": case "durationformat": scope.TimeSpanHandler = TimeSpanHandler.DurationFormat; break; case "sf": case "standardformat": scope.TimeSpanHandler = TimeSpanHandler.StandardFormat; break; } break; case "pc": case "propertyconvention": switch (value) { case "l": case "lenient": scope.PropertyConvention = PropertyConvention.Lenient; break; case "s": case "strict": scope.PropertyConvention = PropertyConvention.Strict; break; } break; case "tc": case "textcase": switch (value) { case "d": case "default": scope.TextCase = TextCase.Default; break; case "pc": case "pascalcase": scope.TextCase = TextCase.PascalCase; break; case "cc": case "camelcase": scope.TextCase = TextCase.CamelCase; break; case "sc": case "snakecase": scope.TextCase = TextCase.SnakeCase; break; } break; } } return(scope); }
public static JsConfigScope CreateScope(string config, JsConfigScope scope = null) { if (string.IsNullOrEmpty(config)) return scope; if (scope == null) scope = BeginScope(); var items = config.Split(','); foreach (var item in items) { var parts = item.SplitOnFirst(':'); var key = parts[0].ToLower(); var value = parts.Length == 2 ? parts[1].ToLower() : null; var boolValue = parts.Length == 1 || (value != "false" && value != "0"); switch (key) { case "cotisd": case "convertobjecttypesintostringdictionary": scope.ConvertObjectTypesIntoStringDictionary = boolValue; break; case "ttpptv": case "trytoparseprimitivetypevalues": scope.TryToParsePrimitiveTypeValues = boolValue; break; case "ttpnt": case "trytoparsenumerictype": scope.TryToParseNumericType = boolValue; break; case "edv": case "excludedefaultvalues": scope.ExcludeDefaultValues = boolValue; break; case "inv": case "includenullvalues": scope.IncludeNullValues = boolValue; break; case "invid": case "includenullvaluesindictionaries": scope.IncludeNullValuesInDictionaries = boolValue; break; case "ide": case "includedefaultenums": scope.IncludeDefaultEnums = boolValue; break; case "eti": case "excludetypeinfo": scope.ExcludeTypeInfo = boolValue; break; case "iti": case "includetypeinfo": scope.IncludeTypeInfo = boolValue; break; case "eccn": case "emitcamelcasenames": scope.EmitCamelCaseNames = boolValue; break; case "elun": case "emitlowercaseunderscorenames": scope.EmitLowercaseUnderscoreNames = boolValue; break; case "pi": case "preferinterfaces": scope.PreferInterfaces = boolValue; break; case "tode": case "throwondeserializationerror": scope.ThrowOnDeserializationError = boolValue; break; case "teai": case "treatenumasinteger": scope.TreatEnumAsInteger = boolValue; break; case "sdtc": case "skipdatetimeconversion": scope.SkipDateTimeConversion = boolValue; break; case "auu": case "alwaysuseutc": scope.AlwaysUseUtc = boolValue; break; case "au": case "assumeutc": scope.AssumeUtc = boolValue; break; case "auo": case "appendutcoffset": scope.AppendUtcOffset = boolValue; break; case "eu": case "escapeunicode": scope.EscapeUnicode = boolValue; break; case "ipf": case "includepublicfields": scope.IncludePublicFields = boolValue; break; case "rsb": case "reuseStringBuffer": scope.ReuseStringBuffer = boolValue; break; case "dh": case "datehandler": switch (value) { case "timestampoffset": case "to": scope.DateHandler = DateHandler.TimestampOffset; break; case "dcjsc": case "dcjscompatible": scope.DateHandler = DateHandler.DCJSCompatible; break; case "iso8601": scope.DateHandler = DateHandler.ISO8601; break; case "iso8601do": case "iso8601dateonly": scope.DateHandler = DateHandler.ISO8601DateOnly; break; case "iso8601dt": case "iso8601datetime": scope.DateHandler = DateHandler.ISO8601DateTime; break; case "rfc1123": scope.DateHandler = DateHandler.RFC1123; break; case "ut": case "unixtime": scope.DateHandler = DateHandler.UnixTime; break; case "utm": case "unixtimems": scope.DateHandler = DateHandler.UnixTimeMs; break; } break; case "tsh": case "timespanhandler": switch (value) { case "df": case "durationformat": scope.TimeSpanHandler = TimeSpanHandler.DurationFormat; break; case "sf": case "standardformat": scope.TimeSpanHandler = TimeSpanHandler.StandardFormat; break; } break; case "pc": case "propertyconvention": switch (value) { case "l": case "lenient": scope.PropertyConvention = PropertyConvention.Lenient; break; case "s": case "strict": scope.PropertyConvention = PropertyConvention.Strict; break; } break; } } return scope; }
internal JsConfigScope() { Thread.BeginThreadAffinity(); parent = head; head = this; }