-3

I have a form, and I need to save the actions made on the control's form has that. For this I have something like this:

 

[NonSerialized()] public EventInfo evento;
public TimeSpan timeToWait;
[NonSerialized()] public Control sender;
public EventArgs eventArgs;
public Type typeOfControl;
public Type typeOfEventArgs;

I need to serialize, but can not serialize the EventArgs, because events can be keyboard mouse, this is all kind of events that can occur on the form.

The purpose of this, and make a recorder, which records all actions taken on the form.

  • 1
    If you get an error message, what does it say? What have you tried? – Andreas Jul 01 '13 at 20:49
  • I have something eventArgs, but they can be anything. Can be MouseEvents, KeyEvents etc, etc.. And I actually thought of creating a class that forbid the important fields. Created for MouseEvents, but as I never know what genre of EventArgs get, can never create a class to store enough. – Victor Morais Jul 02 '13 at 21:29

1 Answers1

0

Do not serialize EventArgs class, but create a class that contains only fields you need to save and restore in binary way.

public EventArgsData {
   public Point MouseCoorrd;
   public MouseButton Button;
   ....

}
Tigran
  • 61,654
  • 8
  • 86
  • 123
  • I have something eventArgs, but they can be anything. Can be MouseEvents, KeyEvents etc, etc.. And I actually thought of creating a class that forbid the important fields. Created for MouseEvents, but as I never know what genre of EventArgs get, can never create a class to store enough. – Victor Morais Jul 02 '13 at 21:30
  • I think you can create for every class you gonna save (shouldn't be more then 5?) its own serialazable mock. – Tigran Jul 02 '13 at 21:37