Table of Contents

Class TypeContractResolver

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

Newtonsoft.Json ContractResolver that only includes certain types from a given assembly. All other types from that assembly are excluded. This allows control over which custom types are serialized.

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

Constructors

TypeContractResolver(Assembly, IEnumerable<Type>)

Define the assembly and the included types. All other types from the assembly will be excluded.

public TypeContractResolver(Assembly entityAssembly, IEnumerable<Type> includedTypes)

Parameters

entityAssembly Assembly
includedTypes IEnumerable<Type>

TypeContractResolver(params Type[])

Define included types. All other types from the same assembly as the first type will be excluded.

public TypeContractResolver(params Type[] includedTypes)

Parameters

includedTypes Type[]

Methods

GetSerializableMembers(Type)

Keep only those properties and fields whose type is included, by IsIncluded(Type).

protected override List<MemberInfo> GetSerializableMembers(Type objectType)

Parameters

objectType Type

The type being serialized.

Returns

List<MemberInfo>

The members to serialize.

IsIncluded(Type)

Whether members of this type should be serialized.

protected bool IsIncluded(Type type)

Parameters

type Type

The member type to test.

Returns

bool

True to serialize members of this type.

Remarks

Arrays and generic collections are unwrapped to their item type first. A type that was named explicitly is included; any other type from the same assembly is excluded; types from elsewhere are left alone.