Questions tagged [custom-attributes]

In .NET Framework, custom attributes are user defined attributes which enable providing metadata for application elements such as assemblies, classes and methods.

In .NET Framework, custom attributes are user defined attributes which enable providing metadata for application elements such as assemblies, classes and methods.

1173 questions
0
votes
1 answer

Possible to get Value from Attribute?

I am using file helpers and I put on top of my class [DelimitedRecord("|")] I want to check though if the value is a "|" if not then I want to throw an exception.. public void WriteResults(IList resultsToWrite, string path, string fileName)…
chobo2
  • 83,322
  • 195
  • 530
  • 832
0
votes
3 answers

Custom attribute with access to input/output parameters of method it is decorating

I was wondering how to go about writing a custom attribute which can access both the input and output parameters of a function. Below is an example of what I wish to achieve [CustomAttribute("Creating Foo")] public Foo CreateFoo(Foo newFoo) { …
Thewads
  • 4,953
  • 11
  • 55
  • 71
0
votes
1 answer

Magento add Sub attribute to attribute?

I need to add a sub attribute into some attribute in magento, am novice to Magneto , For example (Material)Attribute Group Blue -- Dark blue -- Navy blue Pink -- baby pink -- dark pink please let me know this is possible am loosing…
Jothi Kannan
  • 3,320
  • 6
  • 40
  • 77
0
votes
1 answer

Web Api - Authorization on a per-user basis using annotations

is it possible to achieve a user-based authorization procedure using an annotation? I'm building a REST Api and I would like users to only be access items that belong to them. This is achieved by looking at the transmitted AccessToken which contains…
doque
  • 2,723
  • 6
  • 27
  • 44
0
votes
1 answer

Is it possible to create an attribute that behaves as a combination of many others?

I'm basically asking if we can fake some sort of multiple inheritance on attribute classes. I have some view models with a lot of properties that are all getting the same combinations of attributes for field length, formatting, some custom stuff,…
Tesserex
  • 17,166
  • 5
  • 66
  • 106
0
votes
1 answer

Custom ValidationMessageFor and type of error

is there any way to validate using ModelState and model, to determine the type of error? example: [Required] I wanted to make a custom ValidationMessageFor, and within it whether the error is [Required] or other type of error. I am using…
Tiedt Tech
  • 719
  • 15
  • 46
0
votes
3 answers

Custom @Html.ValidationMessageFor

I want to make custom @Html.ValidationMessageFor. I have this code, but it uses @Html.ValidationMessageFor, and now brings the HTML formatted, and only want the return of the errors. How to do this? My code: public static MvcHtmlString…
Tiedt Tech
  • 719
  • 15
  • 46
0
votes
2 answers

A .NET custom attribute to perform impersonation?

I have some methods that need to run as a certain service account, so I do the normal thing: public DoSomeWorkAsServiceAccount() { ... // assume I am given tokenHandle WindowsIdentity newId = new WindowsIdentity(tokenHandle); …
Jeff Meatball Yang
  • 37,839
  • 27
  • 91
  • 125
0
votes
1 answer

Adding attribute to a custom controls in android

I've created a simple custom view that is a rectangle. I can add it to my layout, but can't change its color that is defined in the class. my class: package com.example.customview; import android.content.Context; import…
Hamzeh Soboh
  • 7,572
  • 5
  • 43
  • 54
0
votes
1 answer

MVC3 custom server-side data annotation validation not working in partial view

I am trying to add custom data validation via data annotations. I am only concerned about server-side validation at this point. Everything I have seen here and elsewhere references client-side validation. I've stripped down all my code, ran a few…
0
votes
2 answers

jQuery made up attribute not getting value

Hey all i am trying to get the value of the clicked custom radio button that ive made. Here is the js for the button: $("#df-opt0,#df-opt1,#df-opt2,#df-opt3,#df-opt4").click(function (input) { $('#df-opt0').css("background-image",…
StealthRT
  • 10,108
  • 40
  • 183
  • 342
0
votes
1 answer

Using class attributes instead of const constructor arguments

I've made an application that supports plugins. At the moment, the plugin's base class implements an abstract class and supplies it with the name of the plugin (stuff omitted): public class AppExecutePlugin : APlugin { public AppExecutePlugin()…
Odys
  • 8,951
  • 10
  • 69
  • 111
0
votes
1 answer

Custom Assembly Attribute Issue Across Assemblies

I have the following code in assembly A: [AttributeUsage(AttributeTargets.Assembly)] public class AssemblyCategoryAttribute : Attribute { public string Category { get; set; } public AssemblyCategoryAttribute(string category) { …
nfplee
  • 7,643
  • 12
  • 63
  • 124
0
votes
1 answer

RegularExpressionAttribute javascript encoding

Let's say you have a property Name in your ViewModel: [Required(ErrorMessage = "{0} is required.")] [RegularExpressionAttribute("[a-zA-Z äöåÄÖÅ]+", ErrorMessage = "Field {0} must contain only letters.")] public string Name{ get; set; } …
Matija Grcic
  • 12,963
  • 6
  • 62
  • 90
0
votes
1 answer

Method of updating form values before reaching action in MVC .NET

We received a request from our client that they want every form on their site to store certain fields in a cookie, so that every time after the first submit, the form would be filled in with data from the cookie. We created an actionfilter…
mateuscb
  • 10,150
  • 3
  • 52
  • 76