Table of Contents

Class NHIncludingContractResolver

Namespace
Breeze.Persistence.NH
Assembly
Breeze.Persistence.NH.dll

Newtonsoft.Json ContractResolver that can be configured to include properties by name. Allows JSON serializer to skip certain properties, thus preventing the serializer from trying to serialize the entire object graph. Uses the ClassMetaData from the SessionFactory to determine which types should be serialized by default. Excludes association properties by default, unless explicitly included.

public class NHIncludingContractResolver : DefaultContractResolver, IContractResolver
Inheritance
DefaultContractResolver
NHIncludingContractResolver
Implements
IContractResolver
Inherited Members
DefaultContractResolver.DynamicCodeGeneration
DefaultContractResolver.DefaultMembersSearchFlags
DefaultContractResolver.SerializeCompilerGeneratedMembers
DefaultContractResolver.IgnoreSerializableInterface
DefaultContractResolver.IgnoreSerializableAttribute
DefaultContractResolver.IgnoreIsSpecifiedMembers
DefaultContractResolver.IgnoreShouldSerializeMembers
DefaultContractResolver.NamingStrategy

Constructors

NHIncludingContractResolver(ISessionFactory, IDictionary<Type, List<string>>)

Configure the included property names using a dictionary of { Type -> List of property names to include }

public NHIncludingContractResolver(ISessionFactory sessionFactory, IDictionary<Type, List<string>> includedTypeMembers)

Parameters

sessionFactory ISessionFactory

Supplies the ClassMetaData that decides what is serialized by default

includedTypeMembers IDictionary<Type, List<string>>

Map of { Type -> names of properties to include }

NHIncludingContractResolver(ISessionFactory, params string[])

Configure the included property names using an array of strings

public NHIncludingContractResolver(ISessionFactory sessionFactory, params string[] includedMembers)

Parameters

sessionFactory ISessionFactory

Supplies the ClassMetaData that decides what is serialized by default

includedMembers string[]

Names of properties to be included

Methods

GetSerializableMembers(Type)

Returns the list of property and field names that should be serialized on a given type.

protected override List<MemberInfo> GetSerializableMembers(Type objectType)

Parameters

objectType Type

Returns

List<MemberInfo>

IsIncluded(IClassMetadata, Type, Type, string)

For a given property type, containing type, and property name, return true if it should be serialized and false if not. By default, value types and system types are serialized, but collections and custom types are not.

protected bool IsIncluded(IClassMetadata meta, Type propertyType, Type containingType, string name)

Parameters

meta IClassMetadata
propertyType Type
containingType Type
name string

Returns

bool