Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get custom attributes from a function called by delegate? [modified]

How to get custom attributes from a function called by delegate? [modified]

Scheduled Pinned Locked Moved C#
linqcomfunctionaltutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anindya Chatterjee
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups