Is there a way to tell attribute to work only when used with static methods?
AttributeUsage
class does not seem to allow such specyfic usage.
[AttributeUsage(AttributeTargets.Method,
Inherited = false, AllowMultiple = false)]
A static attribute is an offer field whose value is set once and does not change when the offer is used. When you create an offer template, you supply values for all static attributes.
Static methods are often utility functions, such as functions to create or clone objects, whereas static properties are useful for caches, fixed-configuration, or any other data you don't need to be replicated across instances.
A static method (or static function) is a method defined as a member of an object but is accessible directly from an API object's constructor, rather than from an object instance created via the constructor.
No, there is no way to restrict this. However - you could use reflection at run-time to enforce this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With