How to get custom attributes from a function called by delegate? [modified]
-
suppose I have 3 functions. 1. [CustomAttrib("First")] public int Foo1(ref int x, out float y, SomeDelegate callback) 2. [CustomAttrib("Second")] public Stream Foo2(string name, SomeEnum enums); 3. [CustomAttrib("Third')] public void Foo3(string message, out double count, SomeStruct str); Now what I want to do, is to validate each function according to their attribute. I want to create only one function named Validate which will validate all the above functions and then call them. I tried to use delegate, lambda expression in Validate to pass the function, but nothing can get the attribute data. I already tried : public object Validate(Func<object> method) { .... } and call it as Validate(() => Foo1(ref x, out y, DoCallBack)); or public object Validate(Delegate method) { .... } & call it as Validate(delegate() {return Foo2(null, SomeEnum.EnumValue); }; but none of them can get the attribute information of the called function [Foo1, Foo2 etc.] in the body of Validate function. Can anybody please suggest me any way-around to accomplish this task?
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
modified on Friday, May 22, 2009 12:32 AM