Skip to main content

TypeSerializer

Creates an instance of a Type from a string value

Assembly: ServiceStack.Text.dll​
View Source​
Declaration
public static class TypeSerializer

Properties​

UTF8Encoding​

View Source​
Declaration
[Obsolete("Use JsConfig.UTF8Encoding")]
public static UTF8Encoding UTF8Encoding { get; set; }

OnSerialize​

View Source​
Declaration
public static Action<object> OnSerialize { get; set; }

Fields​

DoubleQuoteString​

View Source​
Declaration
public const string DoubleQuoteString = "\"\""

Methods​

CanCreateFromString(Type)​

Determines whether the specified type is convertible from string.

View Source​
Declaration
public static bool CanCreateFromString(Type type)
Returns​

System.Boolean: true if the specified type is convertible from string; otherwise, false.

Parameters​
TypeNameDescription
System.TypetypeThe type.

|

DeserializeFromString<T>(String)​

Parses the specified value.

View Source​
Declaration
public static T DeserializeFromString<T>(string value)
Returns​

<T>

Parameters​
TypeNameDescription
System.StringvalueThe value.

|

Type Parameters​
  • T

DeserializeFromSpan<T>(ReadOnlySpan<Char>)​

View Source​
Declaration
public static T DeserializeFromSpan<T>(ReadOnlySpan<char> value)
Returns​

<T>

Parameters​
TypeName
ReadOnlySpan<System.Char>value
Type Parameters​
  • T

DeserializeFromReader<T>(TextReader)​

View Source​
Declaration
public static T DeserializeFromReader<T>(TextReader reader)
Returns​

<T>

Parameters​
TypeName
System.IO.TextReaderreader
Type Parameters​
  • T

DeserializeFromString(String, Type)​

Parses the specified type.

View Source​
Declaration
public static object DeserializeFromString(string value, Type type)
Returns​

System.Object

Parameters​
TypeNameDescription
System.StringvalueThe value.

| | System.Type | type | The type.

|

DeserializeFromSpan(Type, ReadOnlySpan<Char>)​

View Source​
Declaration
public static object DeserializeFromSpan(Type type, ReadOnlySpan<char> value)
Returns​

System.Object

Parameters​
TypeName
System.Typetype
ReadOnlySpan<System.Char>value

DeserializeFromReader(TextReader, Type)​

View Source​
Declaration
public static object DeserializeFromReader(TextReader reader, Type type)
Returns​

System.Object

Parameters​
TypeName
System.IO.TextReaderreader
System.Typetype

SerializeToString<T>(T)​

View Source​
Declaration
public static string SerializeToString<T>(T value)
Returns​

System.String

Parameters​
TypeName
<T>value
Type Parameters​
  • T

SerializeToString(Object, Type)​

View Source​
Declaration
public static string SerializeToString(object value, Type type)
Returns​

System.String

Parameters​
TypeName
System.Objectvalue
System.Typetype

SerializeToWriter<T>(T, TextWriter)​

View Source​
Declaration
public static void SerializeToWriter<T>(T value, TextWriter writer)
Parameters​
TypeName
<T>value
System.IO.TextWriterwriter
Type Parameters​
  • T

SerializeToWriter(Object, Type, TextWriter)​

View Source​
Declaration
public static void SerializeToWriter(object value, Type type, TextWriter writer)
Parameters​
TypeName
System.Objectvalue
System.Typetype
System.IO.TextWriterwriter

SerializeToStream<T>(T, Stream)​

View Source​
Declaration
public static void SerializeToStream<T>(T value, Stream stream)
Parameters​
TypeName
<T>value
System.IO.Streamstream
Type Parameters​
  • T

SerializeToStream(Object, Type, Stream)​

View Source​
Declaration
public static void SerializeToStream(object value, Type type, Stream stream)
Parameters​
TypeName
System.Objectvalue
System.Typetype
System.IO.Streamstream

Clone<T>(T)​

View Source​
Declaration
public static T Clone<T>(T value)
Returns​

<T>

Parameters​
TypeName
<T>value
Type Parameters​
  • T

DeserializeFromStream<T>(Stream)​

View Source​
Declaration
public static T DeserializeFromStream<T>(Stream stream)
Returns​

<T>

Parameters​
TypeName
System.IO.Streamstream
Type Parameters​
  • T

DeserializeFromStream(Type, Stream)​

View Source​
Declaration
public static object DeserializeFromStream(Type type, Stream stream)
Returns​

System.Object

Parameters​
TypeName
System.Typetype
System.IO.Streamstream

DeserializeFromStreamAsync(Type, Stream)​

View Source​
Declaration
public static Task<object> DeserializeFromStreamAsync(Type type, Stream stream)
Returns​

System.Threading.Tasks.Task<System.Object>

Parameters​
TypeName
System.Typetype
System.IO.Streamstream

DeserializeFromStreamAsync<T>(Stream)​

View Source​
Declaration
public static async Task<T> DeserializeFromStreamAsync<T>(Stream stream)
Returns​

System.Threading.Tasks.Task<<T>>

Parameters​
TypeName
System.IO.Streamstream
Type Parameters​
  • T

ToStringDictionary(Object)​

Useful extension method to get the Dictionary[string,string] representation of any POCO type.

View Source​
Declaration
public static Dictionary<string, string> ToStringDictionary(this object obj)
Returns​

System.Collections.Generic.Dictionary<System.String,System.String>

Parameters​
TypeName
System.Objectobj

Dump<T>(T)​

Recursively prints the contents of any POCO object in a human-friendly, readable format

View Source​
Declaration
public static string Dump<T>(this T instance)
Returns​

System.String

Parameters​
TypeName
<T>instance
Type Parameters​
  • T

PrintDump<T>(T)​

Print Dump to Console.WriteLine

View Source​
Declaration
public static void PrintDump<T>(this T instance)
Parameters​
TypeName
<T>instance
Type Parameters​
  • T

Print(String, Object[])​

Print string.Format to Console.WriteLine

View Source​
Declaration
public static void Print(this string text, params object[] args)
Parameters​
TypeName
System.Stringtext
System.Object[]args

Print(Int32)​

View Source​
Declaration
public static void Print(this int intValue)
Parameters​
TypeName
System.Int32intValue

Print(Int64)​

View Source​
Declaration
public static void Print(this long longValue)
Parameters​
TypeName
System.Int64longValue

SerializeAndFormat<T>(T)​

View Source​
Declaration
public static string SerializeAndFormat<T>(this T instance)
Returns​

System.String

Parameters​
TypeName
<T>instance
Type Parameters​
  • T

Dump(Delegate)​

View Source​
Declaration
public static string Dump(this Delegate fn)
Returns​

System.String

Parameters​
TypeName
System.Delegatefn

HasCircularReferences(Object)​

View Source​
Declaration
public static bool HasCircularReferences(object value)
Returns​

System.Boolean

Parameters​
TypeName
System.Objectvalue

IndentJson(String)​

View Source​
Declaration
public static string IndentJson(this string json)
Returns​

System.String

Parameters​
TypeName
System.Stringjson