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",FieldLength.Vendor),RequiredValidator("Vendo r Name")]
string Name
{ get;set}
[LengthValidator("Vendor
Number",FieldLength.Vendor),RequiredValidator("Ven dor 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(Eventhoug 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 1 8434
Sorry this is a bug which is fixed in the next version of CLR.
Basically we were unable to get CustomAttribute on PropertyInfo and
EvenInfo on inheritance hierarchy.
You can try to define your own wrapper of GetCustomAttribute on
property so that it will walk the inheritance hierarchy by using
reflection APIs.
Sorry about this.
Yiru
"Microsoft" <ba***@aldensys.com> wrote in message news:<eX**************@TK2MSFTNGP10.phx.gbl>... 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",FieldLength.Vendor),RequiredValidator("Vendo r Name")] string Name { get;set}
[LengthValidator("Vendor Number",FieldLength.Vendor),RequiredValidator("Ven dor 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(Eventhoug 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Doug Holland |
last post by:
Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:
...
|
by: Pol Bawin |
last post by:
Hi All,
Did somebody already define attributes for numerical properties to define
value : minima, maxima, a number of decimal, ...? This information would be
useful to unify syntax
Polo
|
by: News |
last post by:
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
{
|
by: Microsoft |
last post by:
I have Interface defined with custom attribute. My class implements the
same interface , but I'm not able to see any attributes derived from
interface.( I did set the inherited to true) .
|
by: Alex Sedow |
last post by:
Why interface-event-declaration does not support multiple declarators like
event-declaration?
Grammar from C# spec:
variable-declarators:
variable-declarator
variable-declarators ","...
|
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the...
|
by: Bill Rust |
last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a
specialized class that works with my application framework. In the wizard,
the user can select the interfaces they...
|
by: Sergio Montero |
last post by:
I have a MustInherits Base class that implements a custom IDataLayer
interfase. IDataLayer expose CRUD methods. Base class constructor requires
two parameters:
ConnectionString
TableName
...
|
by: Jon Pope |
last post by:
I've got a class which contains properties. I can supply this class to the
Properties control, and it will properly display the properties and allow
the user to edit them, etc. I would like to be...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |