Well I tried a relatively complex example as below and it seems to be
working. I think we can mark it as serializable.
using System;
using System.Console;
using Nemerle.Utility;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Xml.Serialization;
module Program
{
Main() : void
{
def testObject = Doo();
def someList = System.Collections.Generic.List.[Doo]();
someList.Add(testObject);
testObject.InnerList = [someList];
using( def m = MemoryStream())
{
def bf = BinaryFormatter();
bf.Serialize(m,testObject);
m.Seek(0,0);
def newTestObject : Doo = bf.Deserialize(m) :> Doo;
Console.Write(newTestObject.InnerList.Head[0].Foo);
}
}
}
[Serializable]
public class Doo {
public Foo:Foo = Foo.Bar();
public InnerList:list[System.Collections.Generic.List.[Doo]]
{ get; set;}
}
[Serializable]
public variant Foo
{
[Serializable]
|Bar
[Serializable]
|Baz
}
/// Outputs Foo+Bar which is correct.
On Jun 16, 4:14 pm, VladD2 <
v...@rsdn.ru> wrote:
> I think, simple way is implement ISerializable and IDeserializationCallback.
> But I not sure can we modify created instance of list[T].Cons.
>
> What means Nemerle.Extensions.CompilerMutable in tl field?
>
> In worst case we can try use reflection to set fields in OnDeserialization().
>
> 2009/6/16 VladD2 <
v...@rsdn.ru>:
>
> > 2009/6/16 Ķaмĭļ ๏ Şκaļşκĭ <
kamil.skal...@gmail.com>
>
> >> This is not possible for some weird reason. AFAIR it was something
> >> like: if you want to make IEnumerable class serializable, it also
> >> needs to implement ICollection. In case of list['a], which is
> >> immutable, we do not implement ICollection (which has fields like Add
> >> / Remove), so it is not possible... I'm not sure this is exactly the
> >> reason, but something like this - if you try to make list as
> >> serializable and create a testcase, then I think you will get runtime
> >> error explaining it more.
>
> > We can use ISerializable or SerializationSurrogate.
> > Seehttp://
msdn.microsoft.com/en-us/magazine/cc188950.aspx