From: hammett <ha...@uo...> - 2004-10-29 00:06:37
|
Hiya, I was talking to bamboo today and thinking about this problem. One possible solution suggested by him relies on the use of FormatterServices. Henry, can you please check this out? -- Cheers, hammett http://www.digitalcraftsmen.com.br/~hammett |
From: Rodrigo B. de O. <rod...@gm...> - 2004-10-29 00:30:26
|
Something along the following lines if I recall our conversation correctly: <snip> import System import System.IO import System.Runtime.Serialization import System.Runtime.Serialization.Formatters.Binary class Person: [property(FirstName)] _fname = "" [property(LastName)] _lname = "" class PersonProxy(Person, ISerializable): transient _caboosh = 0 def constructor(): pass def constructor(info as SerializationInfo, context as StreamingContext): data = info.GetValue("Person.Data", typeof((object))) FormatterServices.PopulateObjectMembers(self, GetSerializableMembers(), data) def GetObjectData(info as SerializationInfo, context as StreamingContext): members = GetSerializableMembers() info.AddValue("Person.Data", FormatterServices.GetObjectData(self, members)) def GetSerializableMembers(): return FormatterServices.GetSerializableMembers(Person) def serialize(o): stream = MemoryStream() BinaryFormatter().Serialize(stream, o) return stream.GetBuffer() def deserialize(buffer as (byte)): return BinaryFormatter().Deserialize(MemoryStream(buffer)) p = PersonProxy(FirstName: "John", LastName: "Cleese") p = deserialize(serialize(p)) assert "John" == p.FirstName assert "Cleese" == p.LastName </snip> cheers, Rodrigo On Thu, 28 Oct 2004 21:06:20 -0700, hammett <ha...@uo...> wrote: > Hiya, > > I was talking to bamboo today and thinking about this problem. One possible > solution suggested by him relies on the use of FormatterServices. > > Henry, can you please check this out? > > -- > Cheers, > hammett > http://www.digitalcraftsmen.com.br/~hammett > > ------------------------------------------------------- > This Newsletter Sponsored by: Macrovision > For reliable Linux application installations, use the industry's leading > setup authoring tool, InstallShield X. Learn more and evaluate > today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/ > _______________________________________________ > Aspectsharp-users mailing list > Asp...@li... > https://lists.sourceforge.net/lists/listinfo/aspectsharp-users > -- bamboo http://blogs.codehaus.org/people/bamboo/ |
From: <hen...@gm...> - 2004-10-29 17:07:07
|
Sure! I'll make some tests today... On Thu, 28 Oct 2004 22:30:16 -0200, Rodrigo B. de Oliveira <rod...@gm...> wrote: > Something along the following lines if I recall our conversation correctl= y: >=20 > <snip> >=20 > import System > import System.IO > import System.Runtime.Serialization > import System.Runtime.Serialization.Formatters.Binary >=20 > class Person: >=20 > [property(FirstName)] > _fname =3D "" >=20 > [property(LastName)] > _lname =3D "" >=20 > class PersonProxy(Person, ISerializable): >=20 > transient _caboosh =3D 0 >=20 > def constructor(): > pass >=20 > def constructor(info as SerializationInfo, context as StreamingContex= t): > data =3D info.GetValue("Person.Data", typeof((object))) > FormatterServices.PopulateObjectMembers(self, > GetSerializableMembers(), data) >=20 > def GetObjectData(info as SerializationInfo, context as StreamingCont= ext): > members =3D GetSerializableMembers() > info.AddValue("Person.Data", > FormatterServices.GetObjectData(self, members)) >=20 > def GetSerializableMembers(): > return FormatterServices.GetSerializableMembers(Person) >=20 > def serialize(o): > stream =3D MemoryStream() > BinaryFormatter().Serialize(stream, o) > return stream.GetBuffer() >=20 > def deserialize(buffer as (byte)): > return BinaryFormatter().Deserialize(MemoryStream(buffer)) >=20 > p =3D PersonProxy(FirstName: "John", LastName: "Cleese") > p =3D deserialize(serialize(p)) >=20 > assert "John" =3D=3D p.FirstName > assert "Cleese" =3D=3D p.LastName > </snip> >=20 > cheers, > Rodrigo >=20 >=20 >=20 > On Thu, 28 Oct 2004 21:06:20 -0700, hammett <ha...@uo...> wrote: > > Hiya, > > > > I was talking to bamboo today and thinking about this problem. One poss= ible > > solution suggested by him relies on the use of FormatterServices. > > > > Henry, can you please check this out? > > > > -- > > Cheers, > > hammett > > http://www.digitalcraftsmen.com.br/~hammett > > > > ------------------------------------------------------- > > This Newsletter Sponsored by: Macrovision > > For reliable Linux application installations, use the industry's leadin= g > > setup authoring tool, InstallShield X. Learn more and evaluate > > today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/ > > _______________________________________________ > > Aspectsharp-users mailing list > > Asp...@li... > > https://lists.sourceforge.net/lists/listinfo/aspectsharp-users > > >=20 >=20 > -- > bamboo > http://blogs.codehaus.org/people/bamboo/ >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This Newsletter Sponsored by: Macrovision > For reliable Linux application installations, use the industry's leading > setup authoring tool, InstallShield X. Learn more and evaluate > today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/ > _______________________________________________ > Aspectsharp-users mailing list > Asp...@li... > https://lists.sourceforge.net/lists/listinfo/aspectsharp-users >=20 --=20 Cheers, Henry Concei=E7=E3o |