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 / April 2004

Tip: Looking for answers? Try searching our database.

Code generation question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor Irzak - 20 Apr 2004 17:18 GMT
Hello,

I have a class that contains a member which is accessed by get property
only.

public class B {

   public int I {set; get;}
   public string S {set; get;}
}

public class A {
   B m_b = new b();

   public B B {
       get {return m_b;}
   }

}

I'd like to generate code for class A without instantiating a new B object.
It should look something like this:

A a = new A();
a.B.I = 3;
a.B.S = "hehe";

I don't want the code generation to look like this:
A a = new A();
B b = new B();
b.I = 3;
b.S = "hehe";
a.B = b;

How can I do this?

TIA,

Victor
Jeremy Todd - 20 Apr 2004 22:18 GMT
> Hello,
>
[quoted text clipped - 35 lines]
>
> Victor

   What you want to do is use the DesignerSerializationVisibility
attribute, in the System.ComponentModel namespace:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public B B {
 get {return m_b;}
}

   That will tell the designer to generate code persisting the contents of
the property, not assigning the entire property itself.

   Jeremy

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.