Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 707729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:18:40+00:00 2026-05-14T04:18:40+00:00

Well i need some help here i don’t know how to solve this problem.

  • 0

Well i need some help here i don’t know how to solve this problem.

the function of the attribute is to determine if the function can be run…

So what i need is the following:

  1. The consumer of the attribute should
    be able to determine if it can be
    executed.
  2. The owner of the attribute should be
    able to tell the consumer that now it
    can/can’t be executed (like a
    event).
  3. It must have a simple syntax.

This is what i have so far but it only implements point 1, 3.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ExecuteMethodAttribute : Attribute
{
    private Func<object, bool> canExecute;
    public Func<object, bool> CanExecute
    {
        get
        {
            return canExecute;
        }
    }


    public ExecuteMethodAttribute()
    {

    }

    public ExecuteMethodAttribute(Func<object, bool> canExecute)
    {
        this.canExecute = canExecute;
    }
}
  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:18:40+00:00Added an answer on May 14, 2026 at 4:18 am

    Attributes are not intended for this type of purpose. You decorate a Type with an attribute, not a specific instance.

    If you need a way to specify, to a consumer, that a specific method is ready to execute, or cannot execute, I would rethink your design. Instead of using an attribute, perhaps making a custom class would work much more appropriately.

    Given your design, I would recommend taking a look at the ICommand interface. This basically does exactly what you are trying to do. It encapsulates a delegate into a class, with a “CanExecute” method, and an event for notifying “consumers” that the execution availability has changed. This would be a more appropriate option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know MySQL very well so I need a bit of help with
I'm a beginner in ruby and in programming as well and need help with
Well the title pretty well describes my problem. Here is a little bit more
I need your help, i'm stacked on this project. When i run my applicaion
Hopefully this question is not to confusing, but I can help clear it up
I know this isn't a straightforward question but I would really appreciate some feedback
this question probably wont be explained very well and that's because I don't really
I'm sorry if this is too simple for some people, but I still don't
I have searched around but not gotten much help. Here's my problem. I want
I need some help in using objects from Core Data with GCD; I seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.