Class SerializationHelper
Internal utilities for serialization.
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 SourceDefaultSerializer
Default serializer.
Declaration
public static readonly JsonSerializer DefaultSerializer
Field Value
Type | Description |
---|---|
Newtonsoft. |
SerializerSettings
Default serializer settings.
Declaration
public static readonly JsonSerializerSettings SerializerSettings
Field Value
Type | Description |
---|---|
Newtonsoft. |
Methods
| Improve this Doc View SourceAddAtPath(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. |
targetObject | The Newtonsoft. |
System. |
jsonPath | The JsonPath of the new property. |
System. |
content | The property content. |
Returns
Type | Description |
---|---|
Newtonsoft. |
The created Newtonsoft. |
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. |
token | Token to use for populating. |
T | target | Object to populate. |
Newtonsoft. |
serializer | Serializer to use. If null, Default |
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.
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. |
source | Object to remove the property from. |
Newtonsoft. |
target | Object to add the property to. |
System. |
propertyName | Name of the property. |
Remarks
It's not recommended to use this class unless it's required for writing a custom serializer implementation.
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. |
data | Binary data. |
Type Parameters
Name | Description |
---|---|
T | Type of chat message. |
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. |
token | Token to use for populating. |
T | target | Object to populate. |
System. |
childPath | Selector of the child token in the |
Newtonsoft. |
serializer | Serializer to use. If null, Default |
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.
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. |
serializer | Serializer to use. If null, Default |
Returns
Type | Description |
---|---|
Newtonsoft. |
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.