Version 3.3.0.1

CustomSerializationPolicy class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public class CustomSerializationPolicy : ISerializationPolicy
Helper class for quickly and easily implementing the Sirenix.Serialization.ISerializationPolicy interface.
Inheritance
  • System.Object
  • CustomSerializationPolicy

Constructors

CustomSerializationPolicy(String, Boolean, Func<MemberInfo, Boolean>)
Initializes a new instance of the CustomSerializationPolicy class.
public CustomSerializationPolicy(string id, bool allowNonSerializableTypes, Func<MemberInfo, bool> shouldSerializeFunc)
Parameters
System.String id

The policy ID.

System.Boolean allowNonSerializableTypes

if set to true non serializable types will be allowed.

System.Func<System.Reflection.MemberInfo, System.Boolean> shouldSerializeFunc

The delegate to use for determining whether members should be serialized.

Exceptions
System.ArgumentNullException

The id argument or the shouldSerializeFunc argument was null.

Properties

AllowNonSerializableTypes
Gets a value indicating whether to allow non serializable types. (Types which are not decorated with System.SerializableAttribute.)
public bool AllowNonSerializableTypes { get; }
ID
Gets the identifier of the policy. This can be stored in the serialization metadata, so the policy used to serialize it can be recovered without knowing the policy at runtime. This ID should preferably be unique.
public string ID { get; }

Methods

ShouldSerializeMember(MemberInfo)
Gets a value indicating whether a given System.Reflection.MemberInfo should be serialized or not.
public bool ShouldSerializeMember(MemberInfo member)
Parameters
System.Reflection.MemberInfo member

The member to check.

Returns
System.Boolean

true if the given member should be serialized, otherwise, false.