Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forwarding Member Properties, Emulating multiple inheritance

Status
Not open for further replies.

aperion

Programmer
Apr 6, 2004
3
AT
Dear C# wizzards out there ...

I want to achieve a maximum of programming/usage comfort and still keep changes locally. Therfore I would like my class to copy the interface of a member object and forward all Property calls to the respective object.

Instead of:

Code:
class MyClass
{
   MyMemberClass memb;
   
   int Prop1 
   {
      get{return memb.Prop1;}
      set{memb.Prop1=value;}
   }

   string Prop2
   {
      get{return memb.Prop2;}
      set{memb.Prop2=value;}
   }

   // ...

}

I would like to achieve something like the following PSEUDOCODE.

Code:
MyClass.Properties.Add(MyMemberClass.Properties)
foreach (Property prop in MyMemberClass memb)
{
   // pass property calls to member
   get {return memb.prop;}
   set {memb.prop = value;}
}

Does anybody know how to achieve this in C#? Maybe with ComponentModel, Reflection and/or Assembly.

Any help would be greatly appreciated!
Thanks, Aperion
 
I do not see the need for this feature. The MemberInfo class helps you to discover members of a class and maybe there is a way to implement that using : System.Reflection.PropertyInfo , System.Reflection.Emit.PropertyBuilder classes
but the scope of these classes is to build instances of classes at run time.
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top