Interface Properties with Custom Attributes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • News

    #1

    Interface Properties with Custom Attributes

    Hello there,

    I have following situation , how can I solve this puzzle in
    C#.

    I have interface called IVendor with some custom attributes applied to it

    interface IVendor
    {
    [LengthValidator ("Vendor
    Name",FieldLeng th.Vendor),Requ iredValidator(" Vendor Name")]
    string Name
    { get;set}

    [LengthValidator ("Vendor
    Number",FieldLe ngth.Vendor),Re quiredValidator ("Vendor Number")]
    string Number
    {
    get;set;
    }

    }


    Q 1. I have clas called Vendor , Which implement IVendor interface

    Vendor : IVendor
    {

    }

    after I implement all the interface , when I try to get the custom
    attributes defined in IVedndor interface thru reflection,
    I don't see any of my attributes. How can I inherit my custom attribute from
    Interface to the class which implements the interface(Event houg it's Meta
    data) ?

    Q 2 : I have another class callled Invoice Which also implements IVendor
    Interface and contains Vendor as inner class,

    public class Invoice : IVendor
    {
    private Vendor _vendor;

    }

    How can I forward all the properties defined in IVendor infterface to inner
    Vendor class peoperties, without reimplementing those interface in Invoice
    class?

    Thanks
    Baski


Working...