all groups > dotnet windows forms designtime > october 2005 >
You're in the

dotnet windows forms designtime

group:

Code serialization



Code serialization Marcin_Rze=BCnicki
10/16/2005 1:46:25 PM
dotnet windows forms designtime: Hello,
I am currently involved in implementation of custom CodeDomSerializer.
I would like to generate code following the pattern:
System.Drawing.Drawing2D.Blend blend = new
System.Drawing.Drawing2D.Blend(3);
// ... blend property settings ...
MyType gradient = new MyType(... (some params), blend);
myComponent.GradientBackground = gradient; // myComponent is of
MyComponent type

I have two problems with implementing serialization logic described
above.

1) How to ensure that variable named 'blend' has unique name? There is
a possibility that user will create more than one object of MyComponent
type. Therefore I cannot rely on 'blend' variable name being unique, I
should somehow generate that name based upon some information about
serialization context instead eg. how many MyComponents are on design
surface, how may Blend objects have been generated so far etc. What is
the best way to set up and propagate that kind of information?
2) How to generate "final" assignment, which assigns fully constructed
MyType instance to GradientBackground property? The problem is - how do
I know what is the name of MyComponent instance to which I assign the
object?

Thank you in advace for any help
Re: Code serialization Marcin Rzeznicki
10/17/2005 10:32:19 AM
Marcin Rzeznicki napisal(a):

Some afterthought:

[quoted text, click to view]

This problem I have managed to solve by using special object of type
VariableCounter which resposibility is to track how many times variable
was instantiated, that I pass through serialization process by using
CreateInstance method of IDesignerSerializationManager. Seems to be not
so bad design and works just fine so far.
Re: Code serialization Montezuma
11/24/2005 12:00:00 AM
But take a look at
System.ComponentModel.Design.Serialization.INameCreationService

On MSDN is the code of the implementation used by the default designer.

Bye,

Montezuma

[quoted text, click to view]

AddThis Social Bookmark Button