How to trigger IDE code generation?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all

I am writing a custom formatter to serialize controls to a text file. It largely works (at least I keep thinking that)

My current problem is that when a form is deserialized in the designer, the screen is updated properly and the properties show correctly in the editor window, but the newly altered properties do not persist into code. Usually I need to make a slight modification to the objects (e.g. select and move them) for the alterations to persist

I am wondering is there a simple call which will cause the IDE to initiate serialization to code? I suspect I need to somehow get a hold of the IDE's IDesignerSerializationManager object and through it obtain the necessary serializer for my root object and then serialize it - but how do I do that

Thanks for all replies
Marku
 
Try the ShouldSerializeXxx method. It's one of the "magic" methods in .NET.
Let's say you have a property named "MyProperty" that you want serialized,
you can use this to force it:

protected bool ShouldSerializeMyProperty(){
return true;
}

Look at the "ShouldPersist method" topic in the .NET Framework help.

--

markusszil said:
Hello all,

I am writing a custom formatter to serialize controls to a text file. It
largely works (at least I keep thinking that).
My current problem is that when a form is deserialized in the designer,
the screen is updated properly and the properties show correctly in the
editor window, but the newly altered properties do not persist into code.
Usually I need to make a slight modification to the objects (e.g. select and
move them) for the alterations to persist.
I am wondering is there a simple call which will cause the IDE to initiate
serialization to code? I suspect I need to somehow get a hold of the IDE's
IDesignerSerializationManager object and through it obtain the necessary
serializer for my root object and then serialize it - but how do I do that?
 
Sorry to anyone working on a response,

After further testing, the problem appears to be more limited and I probably will attack it from a different angle.

For those interested:
I have created a base control with quite a few properties & methods for automatic layout and custom file serialization. When I want to add support for another windows control, I derive a new class from my base and add an instance of the windows control to the derived class. This creates some redundant properties, but generally works well.

This particular problem appears to be caused by the fact that both my base control and the windows control it wraps have a Font property. At present, only the font property of the windows control is a property capable of being persisted, but since this font matches the font of my base control, nothing is persisted in code. I can alter the font in the designer and the screen changes, and I can use my extensions to serialize to a file and the information is stored correctly, but it never is persisted in code so whenever the project is recompiled all fonts are set back to the default. Then automatic layout code kicks in and moves things around. This led me to believe that other properties weren't being persisted into code, but it now appears that they are. I just need to figure out how to get the font property to correctly persist.

Many thanks to those that contribute to this list,
Markus
 
Back
Top