How could logic be implemented to conditionally prevent an object from being serialized? For example, if the list below is serialized to XML, only 500 of the MyType instances should show up in the result. Whether or not an instance of MyType should be serialized is only known at runtime.
List<MyType> custom_types = new List<MyType>( 1000 );
Filter the list using linq prior to serialization;
serialize(custom_types.where(t = > t.Prop = value).ToList());