This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from paultyng/scope-config
Scope config
- Loading branch information
Showing
3 changed files
with
147 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,73 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Diagnostics; | |||
|
|||
namespace ServiceStack.Text | |||
{ | |||
public sealed class JsConfigScope : IDisposable | |||
{ | |||
bool disposed; | |||
JsConfigScope parent; | |||
|
|||
[ThreadStatic] | |||
private static JsConfigScope head; | |||
|
|||
internal JsConfigScope() | |||
{ | |||
Thread.BeginThreadAffinity(); | |||
parent = head; | |||
head = this; | |||
} | |||
|
|||
internal static JsConfigScope Current | |||
{ | |||
get | |||
{ | |||
return head; | |||
} | |||
} | |||
|
|||
public static void DisposeCurrent() | |||
{ | |||
if (head != null) | |||
{ | |||
head.Dispose(); | |||
} | |||
} | |||
|
|||
public void Dispose() | |||
{ | |||
if (!disposed) | |||
{ | |||
disposed = true; | |||
|
|||
Debug.Assert(this == head, "Disposed out of order."); | |||
|
|||
head = parent; | |||
|
|||
Thread.EndThreadAffinity(); | |||
} | |||
} | |||
|
|||
public bool? ConvertObjectTypesIntoStringDictionary { get; set; } | |||
public bool? TryToParsePrimitiveTypeValues { get; set; } | |||
public bool? IncludeNullValues { get; set; } | |||
public bool? TreatEnumAsInteger { get; set; } | |||
public bool? ExcludeTypeInfo { get; set; } | |||
public bool? IncludeTypeInfo { get; set; } | |||
public string TypeAttr { get; set; } | |||
internal string JsonTypeAttrInObject { get; set; } | |||
internal string JsvTypeAttrInObject { get; set; } | |||
public Func<Type, string> TypeWriter { get; set; } | |||
public Func<string, Type> TypeFinder { get; set; } | |||
public JsonDateHandler? DateHandler { get; set; } | |||
public bool? EmitCamelCaseNames { get; set; } | |||
public bool? EmitLowercaseUnderscoreNames { get; set; } | |||
public bool? ThrowOnDeserializationError { get; set; } | |||
public bool? AlwaysUseUtc { get; set; } | |||
public bool? PreferInterfaces { get; set; } | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters