Class DefaultContractResolver
Used by Json
Implements
Inherited Members
Namespace: Bayat.Json.Serialization
Assembly: Bayat.Json.Runtime.dll
Syntax
public class DefaultContractResolver : IContractResolver
Constructors
| Improve this Doc View SourceDefaultContractResolver()
Initializes a new instance of the Default
Declaration
public DefaultContractResolver()
DefaultContractResolver(Boolean)
Initializes a new instance of the Default
Declaration
[Obsolete("DefaultContractResolver(bool) is obsolete. Use the parameterless constructor and cache instances of the contract resolver within your application for optimal performance.")]
public DefaultContractResolver(bool shareCache)
Parameters
Type | Name | Description |
---|---|---|
System. |
shareCache | If set to |
Properties
| Improve this Doc View SourceDefaultMembersSearchFlags
Gets or sets the default members search flags.
Declaration
[Obsolete("DefaultMembersSearchFlags is obsolete. To modify the members serialized inherit from DefaultContractResolver and override the GetSerializableMembers method instead.")]
public BindingFlags DefaultMembersSearchFlags { get; set; }
Property Value
Type | Description |
---|---|
System. |
The default members search flags. |
DynamicCodeGeneration
Gets a value indicating whether members are being get and set using dynamic code generation. This value is determined by the runtime permissions available.
Declaration
public bool DynamicCodeGeneration { get; }
Property Value
Type | Description |
---|---|
System. |
|
IgnoreSerializableAttribute
Gets or sets a value indicating whether to ignore the System.
Declaration
public bool IgnoreSerializableAttribute { get; set; }
Property Value
Type | Description |
---|---|
System. |
|
IgnoreSerializableInterface
Gets or sets a value indicating whether to ignore the System.
Declaration
public bool IgnoreSerializableInterface { get; set; }
Property Value
Type | Description |
---|---|
System. |
|
Instance
Declaration
public static IContractResolver Instance { get; }
Property Value
Type | Description |
---|---|
IContract |
SerializeCompilerGeneratedMembers
Gets or sets a value indicating whether compiler generated members should be serialized.
Declaration
public bool SerializeCompilerGeneratedMembers { get; set; }
Property Value
Type | Description |
---|---|
System. |
|
Methods
| Improve this Doc View SourceCanConvertToString(Type)
Declaration
public static bool CanConvertToString(Type type)
Parameters
Type | Name | Description |
---|---|---|
System. |
type |
Returns
Type | Description |
---|---|
System. |
CreateArrayContract(Type)
Creates a Json
Declaration
protected virtual JsonArrayContract CreateArrayContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateConstructorParameters(ConstructorInfo, JsonPropertyCollection)
Creates the constructor parameters.
Declaration
protected virtual IList<JsonProperty> CreateConstructorParameters(ConstructorInfo constructor, JsonPropertyCollection memberProperties)
Parameters
Type | Name | Description |
---|---|---|
System. |
constructor | The constructor to create properties for. |
Json |
memberProperties | The type's member properties. |
Returns
Type | Description |
---|---|
System. |
Properties for the given System. |
CreateContract(Type)
Determines which contract type is created for the given type.
Declaration
protected virtual JsonContract CreateContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateDictionaryContract(Type)
Creates a Json
Declaration
protected virtual JsonDictionaryContract CreateDictionaryContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateDynamicContract(Type)
Creates a Json
Declaration
protected virtual JsonDynamicContract CreateDynamicContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateISerializableContract(Type)
Creates a Json
Declaration
protected virtual JsonISerializableContract CreateISerializableContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateLinqContract(Type)
Creates a Json
Declaration
protected virtual JsonLinqContract CreateLinqContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateMemberValueProvider(MemberInfo)
Creates the IValue
Declaration
protected virtual IValueProvider CreateMemberValueProvider(MemberInfo member)
Parameters
Type | Name | Description |
---|---|---|
System. |
member | The member. |
Returns
Type | Description |
---|---|
IValue |
The IValue |
CreateObjectContract(Type)
Creates a Json
Declaration
protected virtual JsonObjectContract CreateObjectContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreatePrimitiveContract(Type)
Creates a Json
Declaration
protected virtual JsonPrimitiveContract CreatePrimitiveContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
CreateProperties(Type, MemberSerialization)
Creates properties for the given Json
Declaration
protected virtual IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
Parameters
Type | Name | Description |
---|---|---|
System. |
type | The type to create properties for. |
Member |
memberSerialization | The member serialization mode for the type. |
Returns
Type | Description |
---|---|
System. |
Properties for the given Json |
CreateProperty(MemberInfo, MemberSerialization)
Creates a Json
Declaration
protected virtual JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
Parameters
Type | Name | Description |
---|---|---|
System. |
member | The member to create a Json |
Member |
memberSerialization | The member's parent Member |
Returns
Type | Description |
---|---|
Json |
A created Json |
CreatePropertyFromConstructorParameter(JsonProperty, ParameterInfo)
Creates a Json
Declaration
protected virtual JsonProperty CreatePropertyFromConstructorParameter(JsonProperty matchingMemberProperty, ParameterInfo parameterInfo)
Parameters
Type | Name | Description |
---|---|---|
Json |
matchingMemberProperty | The matching member property. |
System. |
parameterInfo | The constructor parameter. |
Returns
Type | Description |
---|---|
Json |
A created Json |
CreateStringContract(Type)
Creates a Json
Declaration
protected virtual JsonStringContract CreateStringContract(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
A Json |
GetClrTypeFullName(Type)
Declaration
public static string GetClrTypeFullName(Type type)
Parameters
Type | Name | Description |
---|---|---|
System. |
type |
Returns
Type | Description |
---|---|
System. |
GetResolvedPropertyName(String)
Gets the resolved name of the property.
Declaration
public string GetResolvedPropertyName(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System. |
propertyName | Name of the property. |
Returns
Type | Description |
---|---|
System. |
Name of the property. |
GetSerializableMembers(Type)
Gets the serializable members for the type.
Declaration
protected virtual List<MemberInfo> GetSerializableMembers(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | The type to get serializable members for. |
Returns
Type | Description |
---|---|
System. |
The serializable members for the type. |
GetState()
Declaration
public DefaultContractResolverState GetState()
Returns
Type | Description |
---|---|
Default |
IsIConvertible(Type)
Declaration
public static bool IsIConvertible(Type t)
Parameters
Type | Name | Description |
---|---|---|
System. |
t |
Returns
Type | Description |
---|---|
System. |
IsJsonPrimitiveType(Type)
Declaration
public static bool IsJsonPrimitiveType(Type t)
Parameters
Type | Name | Description |
---|---|---|
System. |
t |
Returns
Type | Description |
---|---|
System. |
ResolveContract(Type)
Resolves the contract for a given type.
Declaration
public virtual JsonContract ResolveContract(Type type)
Parameters
Type | Name | Description |
---|---|---|
System. |
type | The type to resolve a contract for. |
Returns
Type | Description |
---|---|
Json |
The contract for a given type. |
ResolveContractConverter(Type)
Resolves the default Json
Declaration
protected virtual JsonConverter ResolveContractConverter(Type objectType)
Parameters
Type | Name | Description |
---|---|---|
System. |
objectType | Type of the object. |
Returns
Type | Description |
---|---|
Json |
The contract's default Json |
ResolveDictionaryKey(String)
Resolves the key of the dictionary. By default Resolve
Declaration
protected virtual string ResolveDictionaryKey(string dictionaryKey)
Parameters
Type | Name | Description |
---|---|---|
System. |
dictionaryKey | Key of the dictionary. |
Returns
Type | Description |
---|---|
System. |
Resolved key of the dictionary. |
ResolvePropertyName(String)
Resolves the name of the property.
Declaration
protected virtual string ResolvePropertyName(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System. |
propertyName | Name of the property. |
Returns
Type | Description |
---|---|
System. |
Resolved name of the property. |