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
-
DefaultContractResolverTypeContractResolver
- Implements
-
IContractResolver
- Inherited Members
-
DefaultContractResolver.DynamicCodeGenerationDefaultContractResolver.DefaultMembersSearchFlagsDefaultContractResolver.SerializeCompilerGeneratedMembersDefaultContractResolver.IgnoreSerializableInterfaceDefaultContractResolver.IgnoreSerializableAttributeDefaultContractResolver.IgnoreIsSpecifiedMembersDefaultContractResolver.IgnoreShouldSerializeMembersDefaultContractResolver.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
entityAssemblyAssemblyincludedTypesIEnumerable<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
includedTypesType[]
Methods
GetSerializableMembers(Type)
Keep only those properties and fields whose type is included, by IsIncluded(Type).
protected override List<MemberInfo> GetSerializableMembers(Type objectType)
Parameters
objectTypeTypeThe 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
typeTypeThe 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.