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

Read all methode attributes using reflection in C#

I'm trying to read all attributes of a methode which contains more than one attribute of the same type like: [field(Feld = "x86", Index = 1)] [field(Feld = "x93", Index = 2)] ... [field(Feld = "x107", Index = 9)] public string Methodename()…
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
0
votes
2 answers

Inject some dependency to an attribute

I'm developing a multi-language web site. My solution for displaying multilanguage texts, based on following LocalizedDisplayAttribute class. I would like to inject some dependency to this class.But the class is instantiated by .Net Framework. How…
0
votes
1 answer

Seeking to understand this syntax in C# [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="AdventureWorks2008R2")]

I added a Linq to SQL data access class to my project and dragged a table to the design surface and I looked at the code generated in the .cs file. I am trying to understand this…
John Adams
  • 4,773
  • 25
  • 91
  • 131
0
votes
1 answer

.NET Security attribute. Is it possible to make a custom security model?

Common problem: How to implement user access rights differentiation system in any .NET application (for example, WCF application) by using class/method attributes? So, we have: A set of users A set of roles (for example, enum Role) Every user have…
Sir Hally
  • 2,318
  • 3
  • 31
  • 48
0
votes
2 answers

Lambda Expression - is it evaluating correctly?

I have the following piece of code which doesn't seem to be acting right. There is a property which has one attribute which is not of type FieldMapAttribute, but still it goes into the if condition where I am checking the count matching that type of…
0
votes
1 answer

Using decorated attribute on method to call base class method

Is it possible to create a custom attribute (MyAttribute) such that during run-time the get of Derived.MyProperty actually calls Base.GetProperty("MyProperty") and the set of Derived.MyProperty calls Base.SetProperty("MyProperty", value). class…
user481779
  • 1,071
  • 2
  • 14
  • 28
0
votes
2 answers

Defining authentication requirements in MVC3 by action method attribute

I've got an MVC3 application with 4 levels of authentication, and 4 base controllers that tie to each one: Unauthenticated - BaseController User - BaseAuthController : BaseController Advisor - BaseAdvisorController : BaseAuthController Admin -…
jocull
  • 20,008
  • 22
  • 105
  • 149
0
votes
1 answer

Group Properties of a class

I was wondering if it is possible to group properties of a c# class. Something like the following: public class Computer { //First Group public string Name{get;set;} public string IPAddress{get;set;} //Second Group public string…
Anthony Wood
  • 395
  • 1
  • 3
  • 16
0
votes
0 answers

how to use a custom action with the intent I use in my service?

In my manifest I added in my activity: And in my service I launch : Intent close =…
letroll
  • 1,059
  • 1
  • 14
  • 36
0
votes
2 answers

Google Maps API V3 - Dynamic map from XML, custom attributes inaccessible?

I have been building an asp.net control to generate a google map based on an xml file. I have the map working, as well as the popup windows (infoWindows). Unfortunately, for some reason I cannot use the custom attributes within the XML file to…
0
votes
1 answer

Magento: Multiple rows for a single custom attribute of a catalog product?

Here's what I'm trying to do... A given item in our store might be in multiple numerical "Product Groups". We also need to use those product groups to qualify/disqualify those items for coupons and sales rules. If I define "Product Group" as custom…
0
votes
2 answers

.net compact framework deserialization

I have a .net 4 class which it's decorated with a ReadOnly attribute. I'm trying to serialize this class in .NET Compact 3.5 project, but I'm getting an error: "There was an error reflecting type IpSettings" As far as I know .NET CF doesn't include…
0
votes
3 answers

Custom Attribute invocation

I am trying with the Debugger to stop when a method attribute is invoked, but I am never seems to get to the break point. Am I missing something here? [SecurityImpl("test")] public void test() { } [AttributeUsage(AttributeTargets.All)] public…
SexyMF
  • 10,657
  • 33
  • 102
  • 206
0
votes
2 answers

Not getting Validation Erros while applying Validation Attribute on ViewModel

i have a View Model [CustomValidation(typeof(MyValidation), "MyMethod")] [Serializable()] public class TransactionViewModel { public string InvoiceNumber; } public class MyValidation { public static ValidationResult…
Nitin Bourai
  • 430
  • 7
  • 20
0
votes
1 answer

How to access other Model field in custom Model field attribute?

The problem is what i'm trying to create a custom Model field attribute in asp.net mvc3 what needs to access other model field. Named for example "PersonId". So i have a model like this public class PersonWoundModel : IAppointmentModel { …