c# - How serialize one listener and don't serialize other listener of same event -


i have 2 objects(both serializable) in domain model , 1 winform control. first object , winform control listeners of same event of second object. want serialize second object first object listener , without winform control listener.

class secondobject {      public event eventhandler someevent;  }  class firstobject {     secondobject object;     object.someevent += secondobject_someevent(); }  class winformcontrol {     secondobject object;     object.someevent += secondobject_someevent();  } 

right now, so:

class secondobject {      [field: nonserialized]     public event eventhandler someevent;  }  class firstobject {     secondobject object;      [ondeserialized()]     internal void subscribetoeventsondeserialized(streamingcontext context)     {          object.someevent += secondobject_someevent();     }        } 

but can without nonserialized event?

p.s. sorry bad english.

frankly, advise: do not serialize events... ever. pure implementation, where-as serialization should talking data.

with binaryformatter (which is, assume, using) way selectively serialize implement iserializable , work yourself, frankly advise against - advise against serializing events in first place (of course, routinely caution people using binaryformatter in first place, if intent store data somewhere - many horror stories...)


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -