I have a custom collection which derives from Collection<whic h stores
a number of objects. Before each item is added to the collection - an
event which it exposes is hooked by the collection and the re-fired to
its parent.
eg
class MyCollection : Collection<MyTy pe>
{
public AddAnObject(MyT ype obj)
{
obj.SomeEvent += new eventhandler(ob j_somethingChan ged);
base.Add(obj);
}
private void obj_somethingCh anged(object sender, EventArgs e)
{
Do something.....
}
}
The problem I have is that if you serialise and then deserialise the
collection, the events are no longer connected. You could probably fix
this in the deserialisation constructor but Im using CF and this doesnt
support System.Runtime. Serialisation. I can fix it by manually going
through the collection after it has been created and re-connecting but
does anyone know a better way? 7 1922
Hi Nick,
I'm afraid you will have to reattach the events:
Implementing IDeserializatio nCallback on your collection will allow you
to get a callback as soon as deserialization is complete.
Regards,
Wiebe Tijsma http://www.e-office.com
Hi,ni********** *@iinet.net.au wrote:
I have a custom collection which derives from Collection<whic h stores
a number of objects. Before each item is added to the collection - an
event which it exposes is hooked by the collection and the re-fired to
its parent.
eg
class MyCollection : Collection<MyTy pe>
{
public AddAnObject(MyT ype obj)
{
obj.SomeEvent += new eventhandler(ob j_somethingChan ged);
base.Add(obj);
}
private void obj_somethingCh anged(object sender, EventArgs e)
{
Do something.....
}
}
The problem I have is that if you serialise and then deserialise the
collection, the events are no longer connected. You could probably fix
this in the deserialisation constructor but Im using CF and this doesnt
support System.Runtime. Serialisation. I can fix it by manually going
through the collection after it has been created and re-connecting but
does anyone know a better way?
I thought so much :-( Thanks for the hint on the interface though -
I'll give that a shot
On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
Hi Nick,
I'm afraid you will have to reattach the events:
Implementing IDeserializatio nCallback on your collection will allow you
to get a callback as soon as deserialization is complete.
Regards,
Wiebe Tijsmahttp://www.e-office.com
Hi,nick.fletc.. .@iinet.net.au wrote:
I have a custom collection which derives from Collection<whic h stores
a number of objects. Before each item is added to the collection - an
event which it exposes is hooked by the collection and the re-fired to
its parent.
eg
class MyCollection : Collection<MyTy pe>
{
public AddAnObject(MyT ype obj)
{
obj.SomeEvent += new eventhandler(ob j_somethingChan ged);
base.Add(obj);
}
private void obj_somethingCh anged(object sender, EventArgs e)
{
Do something.....
}
}
The problem I have is that if you serialise and then deserialise the
collection, the events are no longer connected. You could probably fix
this in the deserialisation constructor but Im using CF and this doesnt
support System.Runtime. Serialisation. I can fix it by manually going
through the collection after it has been created and re-connecting but
does anyone know a better way?
Hi Nick,
You're welcome :)
If I may give an additional advise:
In my opinion, in most situations where events are used, they can be
replaced by a different architectural design using interfaces or
abstract base classes, especially on scenarios where serialization is
involved.
(events are evil :p)
Regards,
Wiebe Tijsma ni***********@i inet.net.au wrote:
I thought so much :-( Thanks for the hint on the interface though -
I'll give that a shot
On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
>Hi Nick,
I'm afraid you will have to reattach the events:
Implementing IDeserializatio nCallback on your collection will allow you to get a callback as soon as deserialization is complete.
Regards,
Wiebe Tijsmahttp://www.e-office.com
Hi,nick.fletc. ..@iinet.net.au wrote:
>>I have a custom collection which derives from Collection<whic h stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyTy pe> { public AddAnObject(MyT ype obj) { obj.SomeEvent += new eventhandler(ob j_somethingChan ged); base.Add(obj); } private void obj_somethingCh anged(object sender, EventArgs e) { Do something..... } } The problem I have is that if you serialise and then deserialise the collection, the events are no longer connected. You could probably fix this in the deserialisation constructor but Im using CF and this doesnt support System.Runtime. Serialisation. I can fix it by manually going through the collection after it has been created and re-connecting but does anyone know a better way?
Still no joy!
IDeserializatio nCallback is unfortunately a
System.Runtime. Serialization interface and is not supported under CF.
Wrt your last post - how could I change the architecture such that one
class can asynchronously notify another of an event via an
interface/abstract class. I mean, I could also use a delegate but I end
up with the same problem in that serialization will only serialize
public properties
Many thanks
Nick
On Nov 27, 3:29 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
Hi Nick,
You're welcome :)
If I may give an additional advise:
In my opinion, in most situations where events are used, they can be
replaced by a different architectural design using interfaces or
abstract base classes, especially on scenarios where serialization is
involved.
(events are evil :p)
Regards,
Wiebe Tijsma
nick.fletc...@i inet.net.au wrote:
I thought so much :-( Thanks for the hint on the interface though -
I'll give that a shot
On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
Hi Nick,
I'm afraid you will have to reattach the events:
Implementing IDeserializatio nCallback on your collection will allow you
to get a callback as soon as deserialization is complete.
Regards,
Wiebe Tijsmahttp://www.e-office.com
Hi,nick.fletc.. .@iinet.net.au wrote: I have a custom collection which derives from Collection<whic h stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyTy pe> { public AddAnObject(MyT ype obj) { obj.SomeEvent += new eventhandler(ob j_somethingChan ged); base.Add(obj); } private void obj_somethingCh anged(object sender, EventArgs e) { Do something..... } } The problem I have is that if you serialise and then deserialise the collection, the events are no longer connected. You could probably fix this in the deserialisation constructor but Im using CF and this doesnt support System.Runtime. Serialisation. I can fix it by manually going through the collection after it has been created and re-connecting but does anyone know a better way?
Hi Nick,
I'm sorry for the wrong information then, I don't use the CF.
Are you using the XmlSerializer? this will only serialize public properties.
The binary serialization will serialize the in-memory representation of
your objects (fields), not the public properties.
What you could do is implement IEnumerable on your object model, and
iterate through your graph querying your object model for your own
custom interface that requires the callback (IMyCallBack) and execute
that recursively as soon as deserialization is complete.
In that case you can also reattach your events.
Best regards,
Wiebe Tijsma http://www.e-office.com ni***********@i inet.net.au wrote:
Still no joy!
IDeserializatio nCallback is unfortunately a
System.Runtime. Serialization interface and is not supported under CF.
Wrt your last post - how could I change the architecture such that one
class can asynchronously notify another of an event via an
interface/abstract class. I mean, I could also use a delegate but I end
up with the same problem in that serialization will only serialize
public properties
Many thanks
Nick
On Nov 27, 3:29 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
>Hi Nick,
You're welcome :)
If I may give an additional advise:
In my opinion, in most situations where events are used, they can be replaced by a different architectural design using interfaces or abstract base classes, especially on scenarios where serialization is involved.
(events are evil :p)
Regards,
Wiebe Tijsma
nick.fletc...@ iinet.net.au wrote:
>>I thought so much :-( Thanks for the hint on the interface though - I'll give that a shot On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m> wrote: Hi Nick, I'm afraid you will have to reattach the events: Implementi ng IDeserializatio nCallback on your collection will allow you to get a callback as soon as deserialization is complete. Regards, Wiebe Tijsmahttp://www.e-office.com Hi,nick.flet c...@iinet.net. au wrote: I have a custom collection which derives from Collection<whic h stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyTy pe> { public AddAnObject(MyT ype obj) { obj.SomeEvent += new eventhandler(ob j_somethingChan ged); base.Add(obj); } private void obj_somethingCh anged(object sender, EventArgs e) { Do something..... } } The problem I have is that if you serialise and then deserialise the collectio n, the events are no longer connected. You could probably fix this in the deserialisation constructor but Im using CF and this doesnt support System.Runtime. Serialisation. I can fix it by manually going through the collection after it has been created and re-connecting but does anyone know a better way?
Hiya
I actually found a solution
When the collection which holds the objects is deserialized it actually
calls it Add() method on the base class. All I needed to do was
override the add instead of wrapping it and hey presto
Thanks for your help though :-)
On Nov 28, 11:37 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
Hi Nick,
I'm sorry for the wrong information then, I don't use the CF.
Are you using the XmlSerializer? this will only serialize public properties.
The binary serialization will serialize the in-memory representation of
your objects (fields), not the public properties.
What you could do is implement IEnumerable on your object model, and
iterate through your graph querying your object model for your own
custom interface that requires the callback (IMyCallBack) and execute
that recursively as soon as deserialization is complete.
In that case you can also reattach your events.
Best regards,
Wiebe Tijsmahttp://www.e-office.com
nick.fletc...@i inet.net.au wrote:
Still no joy!
IDeserializatio nCallback is unfortunately a
System.Runtime. Serialization interface and is not supported under CF.
Wrt your last post - how could I change the architecture such that one
class can asynchronously notify another of an event via an
interface/abstract class. I mean, I could also use a delegate but I end
up with the same problem in that serialization will only serialize
public properties
Many thanks
Nick
On Nov 27, 3:29 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
Hi Nick,
You're welcome :)
If I may give an additional advise:
In my opinion, in most situations where events are used, they can be
replaced by a different architectural design using interfaces or
abstract base classes, especially on scenarios where serialization is
involved.
(events are evil :p)
Regards,
Wiebe Tijsma
nick.fletc...@i inet.net.au wrote: I thought so much :-( Thanks for the hint on the interface though - I'll give that a shot On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m> wrote: Hi Nick, I'm afraid you will have to reattach the events: Implementin g IDeserializatio nCallback on your collection will allow you to get a callback as soon as deserialization is complete. Regards, Wiebe Tijsmahttp://www.e-office.com Hi,nick.fletc ...@iinet.net.a u wrote: I have a custom collection which derives from Collection<whic h stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and the re-fired to its parent. eg class MyCollection : Collection<MyTy pe> { public AddAnObject(MyT ype obj) { obj.SomeEvent += new eventhandler(ob j_somethingChan ged); base.Add(obj); } private void obj_somethingCh anged(object sender, EventArgs e) { Do something..... } } The problem I have is that if you serialise and then deserialise the collection , the events are no longer connected. You could probably fix this in the deserialisation constructor but Im using CF and this doesnt support System.Runtime. Serialisation. I can fix it by manually going through the collection after it has been created and re-connecting but does anyone know a better way?
Ah, so are you using the XmlSerializer then? ni***********@i inet.net.au wrote:
Hiya
I actually found a solution
When the collection which holds the objects is deserialized it actually
calls it Add() method on the base class. All I needed to do was
override the add instead of wrapping it and hey presto
Thanks for your help though :-)
On Nov 28, 11:37 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m>
wrote:
>Hi Nick,
I'm sorry for the wrong information then, I don't use the CF.
Are you using the XmlSerializer? this will only serialize public properties.
The binary serialization will serialize the in-memory representation of your objects (fields), not the public properties.
What you could do is implement IEnumerable on your object model, and iterate through your graph querying your object model for your own custom interface that requires the callback (IMyCallBack) and execute that recursively as soon as deserialization is complete.
In that case you can also reattach your events.
Best regards,
Wiebe Tijsmahttp://www.e-office.com
nick.fletc...@ iinet.net.au wrote:
>>Still no joy! IDeserializat ionCallback is unfortunately a System.Runtim e.Serialization interface and is not supported under CF. Wrt your last post - how could I change the architecture such that one class can asynchronously notify another of an event via an interface/abstract class. I mean, I could also use a delegate but I end up with the same problem in that serialization will only serialize public properties Many thanks Nick On Nov 27, 3:29 am, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m> wrote: Hi Nick, You're welcome :) If I may give an additional advise: In my opinion, in most situations where events are used, they can be replaced by a different architectural design using interfaces or abstract base classes, especially on scenarios where serialization is involved. (events are evil :p) Regards, Wiebe Tijsma nick.fletc.. .@iinet.net.au wrote: I thought so much :-( Thanks for the hint on the interface though - I'll give that a shot On Nov 24, 10:14 pm, Wiebe Tijsma <wiebeREM...@CA PITALStijsma.co m> wrote: >Hi Nick, >I'm afraid you will have to reattach the events: >Implementi ng IDeserializatio nCallback on your collection will allow you >to get a callback as soon as deserialization is complete. >Regards, >Wiebe Tijsmahttp://www.e-office.com >Hi,nick.fl etc...@iinet.ne t.au wrote: >>I have a custom collection which derives from Collection<whic h stores >>a number of objects. Before each item is added to the collection - an >>event which it exposes is hooked by the collection and the re-fired to >>its parent. >>eg >>class MyCollection : Collection<MyTy pe> >>{ >> public AddAnObject(MyT ype obj) >> { >> obj.SomeEvent += new eventhandler(ob j_somethingChan ged); >> base.Add(obj); >> } >> private void obj_somethingCh anged(object sender, EventArgs e) >> { >> Do something..... >> } >>} >>The problem I have is that if you serialise and then deserialise the >>collectio n, the events are no longer connected. You could probably fix >>this in the deserialisation constructor but Im using CF and this doesnt >>support System.Runtime. Serialisation. I can fix it by manually going >>through the collection after it has been created and re-connecting but >>does anyone know a better way?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: drewnoakes |
last post by:
I have an application that performs custom deserialisation of object state
from byte arrays. This happens very regularly, so needs to be fast. In
addition, most of the strings repeat, meaning I'm deserialising the same
sequence of bytes repeatedly, giving the same output string. Let's ignore
the text encoding method, as it's not relevant to my question.
Right now, I'm using BinaryReader.ReadString() which gives the correct
result,...
|
by: Rick Strahl [MVP] |
last post by:
I'm working on an app that's using the WebBrowser control.
I got the control working fine, hooking to the document object. But I've run
into a major issue with hooking the Document events. Whenever I hook any of
the HTMLDocumnetEvent2_Event events like this:
HTMLDocumentEvents2_Event DocEvents = this.Browser.Document as
HTMLDocumentEvents2_Event ;
DocEvents.oncontextmenu += new...
|
by: Carl Clawson |
last post by:
The C++ compiler is choking on what looks like a valid dispinterface method
declaration.
I have an ATL object "A" that fires COM events, and an object "B" that
receives them. CA is attributed with event_source("com"), and CB contains a
sink object attributed with .
In "B.h" I access A's declarations like this:
;
|
by: Yovi Oktofianus |
last post by:
Hi all,
is it posible to hook every post back event ?
My goal is I want to know which control send post back event to my page
before Page.OnLoad event raised. Or at least in Page_Load event handler i
can find out which control raise it.
Thank's
|
by: John Dann |
last post by:
I need to read a binary file (whose structure I know - at least in
generic terms) and just learning about how best to do it.
Looking at deserialisation this seems to be one direct approach. But
from what I've read thus far I'm unclear about whether a binary file
needs to have been created with serialise before it can be read with
deserialise (ie is there some information added to the file) or can
deserialise be used with any binary file...
| |
by: Jim |
last post by:
I'd like to hook events (like when a user clicks or right-clicks on a link
in a web page) to launch a download manager or to open a new window for the
link, but I am finding it difficult to find sources on how this can be done
using VB.Net.
Have you seen any examples such as this?
I am using VB.Net 2005 Professional, but any .Net examples are welcomed.
Thanks!
|
by: Ryan Ginstrom |
last post by:
Apropos recent threads about GUI editors, coming from a Win32/WTL C++
background, I actually like the idea of being able to (easily) create GUIs
programmatically.
But I still see a lot of the same tedium: hooking up events to handlers, and
getting data into and out of dialogs. In C++, this is generally handled
through code generation and/or macros, but IMO these are brittle and ugly.
So my question: Is there a Pythonic way to make...
|
by: pigeonrandle |
last post by:
Hi,
Has anyone had any experience with hooking messages in other
application windows (like SPY++). I want to listen for WM_MOVE
messages, but can only seem to find examples of Keyboard and Mouse
hooks.
Please (and thankyou),
James Randle.
|
by: Tom Rahav |
last post by:
Hello,
I try to develop application that runs in the background and suppose to
display a small form with menu whenever the user clicks the middle mouse
button (also when my application is not the active one).
I have found a nice way to do it with hooking mouse events and reactring
accordingly. but I'm affriad that this method is a performances killer for
the OS.
Is there a better way to do it? How "killer" is my way anyway?
Thanks!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |