For Programmers: Free Programming Magazines  


Home > Archive > Visual Studio > July 2004 > Redirecting Field to Property during Visual Inheritance:









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Redirecting Field to Property during Visual Inheritance:
Praveen Ramesh

2004-07-22, 8:57 pm

I forgot the attribute that will redirect the vs.net code generator to use a
public Property in a base class instead of a private field in the base
class. Does it ring a bell anybody?

Let me give you an example:

public class MyBaseForm : Form
{
// With this XAttribute, when the derived form below is serialized in
the designer, the code generator will apply
// any changes to this arraylist through the MyList property.
// What is this XAttribute?
[XAttribute("MyList")]
private ArrayList someList;

public ArrayList MyList
{
get{return this.someList;}
}

...

}

In the derived class's InitializeComponent this the code that will be
inserted by the code generator:

public class MyDerivedForm : MyBaseForm
{
...

private void InitializeComponent()
{
...
this.MyList.AddRange(new int[]{1});
}
}

Thanks
-Praveen


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com