attributes

Associate attribute with code generated property in .net

I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file. I have this field: public virtual string Name { get; set; } I wish to set this: [ValidateNonEmpty("Name is required", ExecutionOrder = 1)] public virtual string Name ...

How do I remove a specific node using its attribute value in PHP XML Dom?

My question is best phrase as: http://stackoverflow.com/questions/262351/remove-a-child-with-a-specific-attribute-in-simplexml-for-php except I'm not using simpleXML. I'm new to XML for PHP so I may not be doing the best way I have a xml created using the $dom->save($xml) for each individual user. (not placing all in one xml due to un...

Do auto-implemented properties support attributes?

I was told that in c# attributes are not allowed on the auto-implemented properties. Is that true? if so why? EDIT: I got this information from a popular book on LINQ and could not believe it! EDIT: Refer page 34 of LINQ Unleashed by Paul Kimmel where he says "Attributes are not allowed on auto-implemented properties, so roll your own i...

The replacement to the name attribute...

I am confused. I need to name my iframe in order to use the name as the target in my menu's hypelinks. According to my Visual Web Developer Express the name attribute is considered outdated and a new construct is required. My question is what attrbute code do I utilize to name my iframe. Thank you ...

Does GetCustomAttributes() preserve the attribute order in .NET?

The title pretty much says it all. When I'm doing some reflection through my classes, will the MemberInfo.GetCustomAttributes() method preserve the order of attributes on a member, or not? The official documentation does not say anything one way or the other. In case you're wondering why I would need this, here's the full explanation....

calling methods on an instance with getattr [ python ]

I was trying to write some code that would check if an item has some attributes , and to call them . I tried to do that with getattr , but the modifications wouldn't be permanent . I made a "dummy" class to check upon this . Here is the code I used for the class : class X: def __init__(self):...

Cool uses of Attributes or Annotations (CLR or Java)?

What are some cool applications for custom attributes in CLR/C# code that you've done or heard about? Also interesting new uses of the standard attributes is also ok! Edit: Since Java's annotations seems to be the same as CLR's attrbutes, uses of Java annotations is also valid. ...

Multiple XmlElement attributes on same property/class/...

I'm putting several legacy web services and the current web service into the same back end. But I have to keep the old web services compatible with there old interface. So my question: Is there a way I can set several attributes on, for example, a property? Like this: [XmlElement("AvailableFrom",... what I need...)] [XmlElement("Ava...

OperationBehavior with respect to AutoDisposeParameters - how does WCF behave?

In the context of a WCF service (on the server side), what is the difference between this: [OperationBehavior()] public string TestOperation() { } and this: public string TestOperation() { } In other words, do the default values for each parameter in OperationBehavior already apply even when the attribute isn't put on the method ...

use decimal values as attribute params in c# ?

I have been trying to use decimal values as params for a field attribute but i get a compiler error. I found this blog post link saying it wasn't possible in .Net to use then, does anybody know why they choose this or how can I use decimal params? Thanks. ...

Rails ActiveRecord: Automatically Alias/Append Suffix?

I've got a legacy database with a bunch of idiotically named columns like: some_field_c some_other_field_c a_third_field_c I would very much like to make a Rails ActiveRecord sub-class that automatically aliases these attributes to their name minus the underscore and "c". However, when I tried: attributes.each_key do | key | name =...

How to replace boiler-plate code with attributes?

We have this pattern everywhere in our code: using (ServiceAccess ws = new ServiceAccess()) { //... //code here to talk to webservice ws //... } How can I replace this boiler plate code with an attribute on the functions that need to talk to the web service? (I'm thinking back to when I did some stuff with Hibernate in Java a long tim...

[HandleError] attribute does not seem to act at all...

I am having problems using the [HandleError] attribute on my Controller Actions - it doesn't seem to work at all (i.e. it doesn't matter if the filter is there or not - I get the same results...). When an Exception is thrown, I get the standard red-toned Server Error in '/' Application error page instead of my custom view. I have found ...

How to filter or find properties based on attributes

I have a class as follows Public Class Foo Private _Name As String <ShowInDisplay()> _ Public Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property Private _Age As String Public Property Age() As St...

JQuery , set attribute for <a> tag

i am use $(expr).attr("hash",value) to set a "hash" attribute for HTML anchor element "a" but the Jquery would not do that. but if i change expr to "div", then i can set "hash" attribute to "div" tag. is this behavior a xhtml specification? i can set "id" of "a" tag attribute. since id is a built in attribute for html "a" tag. ...

Can I get Moq to add attributes to the mock class?

I'm writing a command-line interface to my project. The user enters "create project foo", and it finds the controller responsible for "project" and then invokes the Create method, passing "foo" as the first argument. It relies heavily on attributes and reflection: the controller looks something like this: [ControllerFor("project")] cla...

Can a C# class inherit attributes from its interface?

This would appear to imply "no". Which is unfortunate. [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public class CustomDescriptionAttribute : Attribute { public string Description { get; private set; } public CustomDescriptionAttribute(string description) { ...

XSLT - How to select XML Attribute by Attribute?

Hello, this is the structure of my source xml: <root> <DataSet Value="A"> <Data Value1="1" Value2="anythingA1" /> <Data Value1="2" Value2="anythingA2" /> <Data Value1="3" Value2="anythingA3" /> <Data Value1="4" Value2="anythingA4" /> <Data Value1="5" Value2="anythingA5" /> </DataSet> </root> from which I like to create some variables ...

Where did C#'s attributes come from?

I find C#'s Attributes, Python's Properties too a really nice idea, and I guess their direct ancestor might have come from Java's Annotations, but I'm curious as to where this concept originally came from, anyone has any clues? ...

Custom attributes in web service having odd behaviour

I have created two custom attributes one for validating a soap request and authorization. Each having its own seperate class to overide processMessage For a reason unclear to me, when i assign a method with my authorization attribute it inisits on entering my validationExtension class. I understand that from the MDSN: "Initialize is c...