Class RoundtripDataHelper
Serialization related helpers used by the code generated by the Neon.ModelGen library.
Namespace: Neon.Data
Assembly: Neon.Common.dll
Syntax
public static class RoundtripDataHelper
Fields
NoHashPropertiesError
The error message used when GetHashCode() is called on a generated data model that has no properties tagged with [HashSource].
Declaration
public const string NoHashPropertiesError = "At least one data model property must be tagged by [HashSourceAttribute]."
Field Value
Type | Description |
---|---|
string |
Properties
Serializer
Returns the Json global serializer.
Declaration
public static JsonSerializer Serializer { get; }
Property Value
Type | Description |
---|---|
JsonSerializer |
Methods
DeepClone(JObject)
Returns a deep clone of a JObject.
Declaration
public static JObject DeepClone(JObject jObject)
Parameters
Type | Name | Description |
---|---|---|
JObject | jObject | The JObject or |
Returns
Type | Description |
---|---|
JObject | The cloned instance. |
Deserialize<T>(string)
Deserializes a value from JSON text.
Declaration
public static T Deserialize<T>(string jsonText)
Parameters
Type | Name | Description |
---|---|---|
string | jsonText | The JSON text. |
Returns
Type | Description |
---|---|
T | The deserialized value. |
Type Parameters
Name | Description |
---|---|
T | The result type. |
FromObject(object, Type, string)
Used to convert a value into a JToken suitable for assigning as a property to the backing JObject of a generated data model
Declaration
public static JToken FromObject(object value, Type objectType, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
object | value | The value being assigned. |
Type | objectType | The generated data model type. |
string | propertyName | The property name. |
Returns
Type | Description |
---|---|
JToken | The JToken. |
GetPersistedKey(string, params object[])
Generates an database key for a persisted entity from one or more arguments.
Declaration
public static string GetPersistedKey(string persistedType, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
string | persistedType | The entity type string. |
object[] | args | Arguments identifying the entity. |
Returns
Type | Description |
---|---|
string | The generated database key. |
PersistableInitialize()
This examines all loaded assemblies, looking for classes that implement IPersistableType
and then calling each matching type's static PersistableInitialize()
method to ensure that
the class' type filter is registered with Linq2Couchbase.
note
This method scans the assemblies only the first time the method is called. Subsequent calls will jsut return without doing anything.
Declaration
public static void PersistableInitialize()
Serialize(object, Formatting)
Serializes a value to JSON text.
Declaration
public static string Serialize(object value, Formatting format = null)
Parameters
Type | Name | Description |
---|---|---|
object | value | The the value to be serialized. |
Formatting | format | Optionally format the output. |
Returns
Type | Description |
---|---|
string | The JSON text. |