custom-attributes Questions
3
Solved
I want to write my enum with custom attributes, for example:
public enum SomeEnum: long
{
[SomeAttribute<MyClass1>]
Sms = 1,
[SomeAttribute<MyClass2>]
Email = 2
}
but attributes ...
Plebeian asked 23/10, 2014 at 5:9
9
Solved
Question based on MSDN example.
Let's say we have some C# classes with HelpAttribute in standalone desktop application. Is it possible to enumerate all classes with such attribute? Does it make se...
Barnaul asked 3/3, 2009 at 16:43
7
Solved
Let's say I have a class called Test with one property called Title with a custom attribute:
public class Test
{
[DatabaseField("title")]
public string Title { get; set; }
}
And an extension m...
Chiffon asked 24/2, 2010 at 21:36
4
I've been struggling to find examples of how to write a custom attribute to validate method parameters, i.e., turn this form:
public void DoSomething(Client client)
{
if (client.HasAction("do_som...
Harpist asked 17/6, 2013 at 14:44
3
Solved
I just want to put conditional Required Attribute which is work with WEB API
Example
public sealed class EmployeeModel
{
[Required]
public int CategoryId{ get; set; }
public string Email{ get;...
Tirol asked 17/12, 2013 at 18:52
9
Solved
For example—say I want to add a helloWorld() method to Python's dict type. Can I do this?
JavaScript has a prototype object that behaves this way. Maybe it's bad design and I should subclass...
Atheling asked 15/1, 2011 at 7:27
5
Solved
I have the following custom attribute, which can be applied on properties:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class IdentifierAttribute : Attribute
{
}
For...
Twelfthtide asked 20/7, 2010 at 10:51
7
Solved
I have an enum where each member has a custom attribute applied to it. How can I retrieve the value stored in each attribute?
Right now I do this:
var attributes = typeof ( EffectType ).GetCustom...
Koonce asked 23/2, 2011 at 22:3
2
Consider the following scenario:
A base attribute class BaseAttribute has an AttributeUsageAttribute specifying that it is not inheritable (Inherited = False).
A derived attribute class DerivedAt...
Modern asked 19/2, 2013 at 10:39
4
Solved
I recently discovered that a .NET attribute can only contain primitive types, strings, enums, objects, and single parameter arrays of these types as discussed here.
I have the need to accept an ID...
Gustative asked 21/1, 2014 at 17:45
4
Solved
How can I retrieve a Button custom attribute after the attribute value has been changed using javascript?
Example:
Asp file
<asp:Button ID="Button1" runat="server" Text="Button1" />
<as...
Maharanee asked 26/8, 2014 at 13:55
7
Solved
I've written my custom View and i want to update some other views after interacting with my custom view.
Main Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:androi...
Clementinaclementine asked 29/8, 2013 at 10:22
4
Solved
I'd like to ensure that two interfaces are never found on the same class at compile-time, similar to how AttributeUsage checks custom Attributes at compile-time.
e.g.:
[InterfaceUsage(MutuallyExc...
Detritus asked 9/5, 2011 at 12:54
5
Writing custom code to create product detail page with wordpress database.
I have displayed product title, desc, price, stock, etc and got stuck up with product attributes.
In the database, _produ...
Slopwork asked 26/2, 2014 at 7:40
4
Solved
I noticed today that some new properties had appeared in my intellisense on the System.Type object for my .NET 4.5 projects. Among these was one called CustomAttributes.
I was intrigued by this si...
Hagiocracy asked 4/6, 2015 at 0:1
4
Solved
React Typescript allow to add custom data-* attributes.
But is it possible to add custom attributes like 'name' || 'test' act. ?
<span name="I'm causing a type error" data-test="I'm Working"/&g...
Prescott asked 25/2, 2019 at 15:40
5
Solved
I wrote a somewhat generic deserialization mechanism that allows me to construct objects from a binary file format used by a C++ application.
To keep things clean and easy to change, I made a Fiel...
Claymore asked 29/4, 2011 at 8:56
3
Solved
Is it possible to write an Attribute that can track methods to detect if those methods are never called?
[Track]
void MyMethod(){
}
output:
warning: method "MyMethod" in "MyClass" has no refer...
Semblance asked 13/2, 2017 at 13:49
4
Solved
I have a custom Attribute called AuthoriseAttribute whose constructor looks like this:
public AuthoriseAttribute(int userId)
{
.. blah
}
This is used with a method called GetUserDetails() like ...
Yep asked 3/5, 2012 at 16:20
2
Solved
I have an async method that evaluates a field.
Task<bool> MyMethod(object obj);
I want to create a custom validation attribute that uses the above method.
My problem is that the ValidationAt...
Ridenour asked 27/8, 2020 at 4:45
4
Solved
Can anyone please explain to me a very basic example of a custom attribute with code?
Lathe asked 2/2, 2011 at 20:29
0
I am trying to use MethodDevorator.Fody to enable Attribute based method interception.
https://github.com/Fody/MethodDecorator/blob/master/readme.md#your-code
I wanted to create a reusable compon...
Visionary asked 4/6, 2020 at 8:56
9
Solved
I am trying to create a generic method that will read an attribute on a class and return that value at runtime. How do would I do this?
Note: DomainName attribute is of class DomainNameAttribute....
Waneta asked 16/4, 2010 at 21:25
5
Solved
Checking out the sample code from http://lukesampson.com/post/471548689/entering-and-exiting-https-with-asp-net-mvc written for ASP.NET MVC2, I noticed they can check if a custom attribute is appli...
Dyanne asked 25/8, 2010 at 19:2
2
Solved
I want to get a custom attribute value from multiple select.
Here is my HTML code:
<select multiple name="tax[]" id="tax_classes" onChange="getSelectedOptions(this)"...
Priscillaprise asked 28/10, 2019 at 9:33
1 Next >
© 2022 - 2025 — McMap. All rights reserved.