Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class SerializationHelper

    Internal utilities for serialization.

    Inheritance
    System.Object
    SerializationHelper
    Namespace: TehGM.Wolfringo.Messages.Serialization.Internal
    Assembly: Wolfringo.Core.dll
    Syntax
    public static class SerializationHelper
    Remarks

    It's not recommended to use this class unless it's required for writing a custom serializer implementation.

    Fields

    | Improve this Doc View Source

    DefaultSerializer

    Default serializer.

    Declaration
    public static readonly JsonSerializer DefaultSerializer
    Field Value
    Type Description
    Newtonsoft.Json.JsonSerializer
    | Improve this Doc View Source

    SerializerSettings

    Default serializer settings.

    Declaration
    public static readonly JsonSerializerSettings SerializerSettings
    Field Value
    Type Description
    Newtonsoft.Json.JsonSerializerSettings

    Methods

    | Improve this Doc View Source

    AddAtPath(JObject, String, Object)

    Adds a new JProperty at given JsonPath. Note that only dot-notated child syntax is currently supported.

    Declaration
    public static JProperty AddAtPath(this JObject targetObject, string jsonPath, object content)
    Parameters
    Type Name Description
    Newtonsoft.Json.Linq.JObject targetObject

    The Newtonsoft.Json.Linq.JObject to add property to.

    System.String jsonPath

    The JsonPath of the new property.

    System.Object content

    The property content.

    Returns
    Type Description
    Newtonsoft.Json.Linq.JProperty

    The created Newtonsoft.Json.Linq.JProperty.

    | Improve this Doc View Source

    FlattenCommonProperties<T>(JToken, T, JsonSerializer)

    Populates object by "flattening" common properties like "body" or "body.extended" into target object.

    Declaration
    public static void FlattenCommonProperties<T>(this JToken token, T target, JsonSerializer serializer = null)
    Parameters
    Type Name Description
    Newtonsoft.Json.Linq.JToken token

    Token to use for populating.

    T target

    Object to populate.

    Newtonsoft.Json.JsonSerializer serializer

    Serializer to use. If null, DefaultSerializer will be used.

    Type Parameters
    Name Description
    T

    Type of the object.

    Remarks

    It's not recommended to use this class unless it's required for writing a custom serializer implementation.

    | Improve this Doc View Source

    MovePropertyIfExists(ref JObject, ref JObject, String)

    Moves json property from one object to another.

    Declaration
    public static void MovePropertyIfExists(ref JObject source, ref JObject target, string propertyName)
    Parameters
    Type Name Description
    Newtonsoft.Json.Linq.JObject source

    Object to remove the property from.

    Newtonsoft.Json.Linq.JObject target

    Object to add the property to.

    System.String propertyName

    Name of the property.

    Remarks

    It's not recommended to use this class unless it's required for writing a custom serializer implementation.

    | Improve this Doc View Source

    PopulateMessageRawData<T>(ref T, IEnumerable<Byte>)

    Populates chat message's raw data.

    Declaration
    public static void PopulateMessageRawData<T>(ref T message, IEnumerable<byte> data)
        where T : IRawDataMessage
    Parameters
    Type Name Description
    T message

    Chat message.

    System.Collections.Generic.IEnumerable<System.Byte> data

    Binary data.

    Type Parameters
    Name Description
    T

    Type of chat message.

    | Improve this Doc View Source

    PopulateObject<T>(JToken, T, String, JsonSerializer)

    Populates object with Json token's properties.

    Declaration
    public static void PopulateObject<T>(this JToken token, T target, string childPath = null, JsonSerializer serializer = null)
    Parameters
    Type Name Description
    Newtonsoft.Json.Linq.JToken token

    Token to use for populating.

    T target

    Object to populate.

    System.String childPath

    Selector of the child token in the token.

    Newtonsoft.Json.JsonSerializer serializer

    Serializer to use. If null, DefaultSerializer will be used.

    Type Parameters
    Name Description
    T

    Type of the object.

    Remarks

    It's not recommended to use this class unless it's required for writing a custom serializer implementation.

    | Improve this Doc View Source

    SerializeJsonPayload<T>(T, JsonSerializer)

    Serializes Wolf message.

    Declaration
    public static JObject SerializeJsonPayload<T>(this T message, JsonSerializer serializer = null)
        where T : IWolfMessage
    Parameters
    Type Name Description
    T message

    Message to serialize.

    Newtonsoft.Json.JsonSerializer serializer

    Serializer to use. If null, DefaultSerializer will be used.

    Returns
    Type Description
    Newtonsoft.Json.Linq.JObject

    Serialized message object.

    Type Parameters
    Name Description
    T

    Type of the message.

    Remarks

    It's not recommended to use this class unless it's required for writing a custom serializer implementation.