Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / November 2005

Tip: Looking for answers? Try searching our database.

Code serialization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcin Rzeźnicki - 16 Oct 2005 21:46 GMT
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
Marcin Rzeznicki - 17 Oct 2005 18:32 GMT
Marcin Rzeznicki napisal(a):

Some afterthought:

> 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
[quoted text clipped - 3 lines]
> 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?

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.
Montezuma - 24 Nov 2005 15:57 GMT
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

> Marcin Rzeznicki napisal(a):
>
[quoted text clipped - 13 lines]
> CreateInstance method of IDesignerSerializationManager. Seems to be not
> so bad design and works just fine so far.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.