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
-
DefaultContractResolverNHIncludingContractResolver
- Implements
-
IContractResolver
- Inherited Members
-
DefaultContractResolver.DynamicCodeGenerationDefaultContractResolver.DefaultMembersSearchFlagsDefaultContractResolver.SerializeCompilerGeneratedMembersDefaultContractResolver.IgnoreSerializableInterfaceDefaultContractResolver.IgnoreSerializableAttributeDefaultContractResolver.IgnoreIsSpecifiedMembersDefaultContractResolver.IgnoreShouldSerializeMembersDefaultContractResolver.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
sessionFactoryISessionFactorySupplies the ClassMetaData that decides what is serialized by default
includedTypeMembersIDictionary<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
sessionFactoryISessionFactorySupplies the ClassMetaData that decides what is serialized by default
includedMembersstring[]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
objectTypeType
Returns
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)