[Mono-list] OnDeserialization problem

Dave Null eric.jacoboni at gmail.com
Mon Mar 23 12:35:44 EDT 2009




Dave Null wrote:
> 
> I'm trying to use the IDeserializationCallback interface with Mono 2.2  on
> OS X 1.5.6 :
> (...)
> [Serializable] 
> class Truc : IDeserializationCallback {
> 	private int limite;
> 	[NonSerialized] private int[] tab;
>        (...)
>        public virtual void OnDeserialization(Object sender) {
>           tab = new int[limite];
> 	  for (int i = 0; i < limite; i++) {
> 	    tab[i] = i + 42;
> 	  }
> 	}
> (...)
> }
> 

BTW... What is the preferred way to achieve this kind of stuff ?

1) using IDeserializationCallback interface and implementing
OnDeserialization() method, as i've done above
2) or, simply using [OnDeserializated] attribute as in:

[Serializable] 
class Truc {
	private int limite;
	[NonSerialized] private int[] tab;
       (...)
       [OnDeserialized]
       public void OnDeserialized(StreamingContext context) {
          tab = new int[limite];
	  for (int i = 0; i < limite; i++) {
	    tab[i] = i + 42;
	  }
	}
(...)
}

-- 
View this message in context: http://www.nabble.com/OnDeserialization-problem-tp22234369p22663867.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list