TypeSerializer
Creates an instance of a Type from a string value
Assembly: ServiceStack.Text.dll
View Source
public static class TypeSerializer
Properties
UTF8Encoding
View Source
[Obsolete("Use JsConfig.UTF8Encoding")]
public static UTF8Encoding UTF8Encoding { get; set; }
OnSerialize
View Source
public static Action<object> OnSerialize { get; set; }
Fields
DoubleQuoteString
View Source
public const string DoubleQuoteString = "\"\""
Methods
CanCreateFromString(Type)
Determines whether the specified type is convertible from string.
View Source
public static bool CanCreateFromString(Type type)
Returns
System.Boolean
:
true
if the specified type is convertible from string; otherwise, false
.
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type. |
|
DeserializeFromString<T>(String)
Parses the specified value.
View Source
public static T DeserializeFromString<T>(string value)
Returns
<T>
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value. |
|
Type Parameters
T
DeserializeFromSpan<T>(ReadOnlySpan<Char>)
View Source
public static T DeserializeFromSpan<T>(ReadOnlySpan<char> value)
Returns
<T>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | value |
Type Parameters
T
DeserializeFromReader<T>(TextReader)
View Source
public static T DeserializeFromReader<T>(TextReader reader)
Returns
<T>
Parameters
Type | Name |
---|---|
System.IO.TextReader | reader |
Type Parameters
T
DeserializeFromString(String, Type)
Parses the specified type.
View Source
public static object DeserializeFromString(string value, Type type)
Returns
System.Object
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value. |
|
| System.Type
| type | The type.
|
DeserializeFromSpan(Type, ReadOnlySpan<Char>)
View Source
public static object DeserializeFromSpan(Type type, ReadOnlySpan<char> value)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.Type | type |
ReadOnlySpan<System.Char> | value |
DeserializeFromReader(TextReader, Type)
View Source
public static object DeserializeFromReader(TextReader reader, Type type)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.IO.TextReader | reader |
System.Type | type |
SerializeToString<T>(T)
View Source
public static string SerializeToString<T>(T value)
Returns
System.String
Parameters
Type | Name |
---|---|
<T> | value |
Type Parameters
T
SerializeToString(Object, Type)
View Source
public static string SerializeToString(object value, Type type)
Returns
System.String
Parameters
Type | Name |
---|---|
System.Object | value |
System.Type | type |
SerializeToWriter<T>(T, TextWriter)
View Source
public static void SerializeToWriter<T>(T value, TextWriter writer)
Parameters
Type | Name |
---|---|
<T> | value |
System.IO.TextWriter | writer |
Type Parameters
T
SerializeToWriter(Object, Type, TextWriter)
View Source
public static void SerializeToWriter(object value, Type type, TextWriter writer)
Parameters
Type | Name |
---|---|
System.Object | value |
System.Type | type |
System.IO.TextWriter | writer |
SerializeToStream<T>(T, Stream)
View Source
public static void SerializeToStream<T>(T value, Stream stream)
Parameters
Type | Name |
---|---|
<T> | value |
System.IO.Stream | stream |
Type Parameters
T
SerializeToStream(Object, Type, Stream)
View Source
public static void SerializeToStream(object value, Type type, Stream stream)
Parameters
Type | Name |
---|---|
System.Object | value |
System.Type | type |
System.IO.Stream | stream |
Clone<T>(T)
View Source
public static T Clone<T>(T value)
Returns
<T>
Parameters
Type | Name |
---|---|
<T> | value |
Type Parameters
T
DeserializeFromStream<T>(Stream)
View Source
public static T DeserializeFromStream<T>(Stream stream)
Returns
<T>
Parameters
Type | Name |
---|---|
System.IO.Stream | stream |
Type Parameters
T
DeserializeFromStream(Type, Stream)
View Source
public static object DeserializeFromStream(Type type, Stream stream)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.Type | type |
System.IO.Stream | stream |
DeserializeFromStreamAsync(Type, Stream)
View Source
public static Task<object> DeserializeFromStreamAsync(Type type, Stream stream)
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
System.Type | type |
System.IO.Stream | stream |
DeserializeFromStreamAsync<T>(Stream)
View Source
public static async Task<T> DeserializeFromStreamAsync<T>(Stream stream)
Returns
System.Threading.Tasks.Task<<T>>
Parameters
Type | Name |
---|---|
System.IO.Stream | stream |
Type Parameters
T
ToStringDictionary(Object)
Useful extension method to get the Dictionary[string,string] representation of any POCO type.
View Source
public static Dictionary<string, string> ToStringDictionary(this object obj)
Returns
System.Collections.Generic.Dictionary<System.String,System.String>
Parameters
Type | Name |
---|---|
System.Object | obj |
Dump<T>(T)
Recursively prints the contents of any POCO object in a human-friendly, readable format
View Source
public static string Dump<T>(this T instance)
Returns
System.String
Parameters
Type | Name |
---|---|
<T> | instance |
Type Parameters
T
PrintDump<T>(T)
Print Dump to Console.WriteLine
View Source
public static void PrintDump<T>(this T instance)
Parameters
Type | Name |
---|---|
<T> | instance |
Type Parameters
T
Print(String, Object[])
Print string.Format to Console.WriteLine
View Source
public static void Print(this string text, params object[] args)
Parameters
Type | Name |
---|---|
System.String | text |
System.Object[] | args |
Print(Int32)
View Source
public static void Print(this int intValue)
Parameters
Type | Name |
---|---|
System.Int32 | intValue |
Print(Int64)
View Source
public static void Print(this long longValue)
Parameters
Type | Name |
---|---|
System.Int64 | longValue |
SerializeAndFormat<T>(T)
View Source
public static string SerializeAndFormat<T>(this T instance)
Returns
System.String
Parameters
Type | Name |
---|---|
<T> | instance |
Type Parameters
T
Dump(Delegate)
View Source
public static string Dump(this Delegate fn)
Returns
System.String
Parameters
Type | Name |
---|---|
System.Delegate | fn |
HasCircularReferences(Object)
View Source
public static bool HasCircularReferences(object value)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Object | value |
IndentJson(String)
View Source
public static string IndentJson(this string json)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | json |