attributes

Syntax for applying an attribute to an anonymous method?

This is related to the question about return type attributes and anonymous classes, but then for anonymous methods (or lambdas), but as far I could find this exact question does not seem to be on stackoverflow yet. In code for business entities that we generate using CodeSmith we now have [DebuggerNonUserCode] attributes, so they don't ...

Can E4X Get Attribute of a Parent Node Based on Attribute of a Child At Any Level?

Hi, I'm struggling with some E4X and hope you can help. Here's my XML structure: <xml> <node type="bar"> <subnode id="4"> <subnode id="5"/> </subnode> <subnode id="6"/> </node> <node type="foo"> <subnode id="7"> <subnode id="8"> <subnode id="9"/> </subno...

Using an Enum as an Attribute Argument

Here is the code I would like to use: public enum Days { Sat = 1, Sun, Mon, Tue, Wed, Thu, Fri }; [EnumHelper(typeof(Days))] public Days DayOfWeek { get; set; } EnumHelper looks like: [AttributeUsage(AttributeTargets.Property,AllowMultiple=true)] public class EnumHelper : Attribute { public Type MyEnum { get; set; } public E...

Having a problem utilizing xs:unique

Can anyone point me as to why the unique element in my XSD is not forcing unique-ness? This should throw an error because the last ScreenResult element does not contain a unique value for the Type attribute. I should also note that I'm truly after forcing one of each Type within ScreenResults (ScreenResult is required to exist 3 times,...

Custom attributes in C#

Hello I have a custom attribute for my page like this: [PageDefinition("My page", "~/Parts/MyPage.aspx")] My PageDefinition looks like this, where AttributeItemDefinitions is get set for Title, Url, IsPage and IsUserControl public class PageDefinition : AttributeItemDefinitions { public PageDefinition(string title, string url) ...

Using XSL to sort attributes

I'm trying to canonicalize the representation of some XML data by sorting each element's attributes by name (not value). The idea is to keep textual differences minimal when attributes are added or removed and to prevent different editors from introducing equivalent variants. These XML files are under source control and developers are wa...

C# creating attribute that indicate running code after property call

Hello, I would like to create an Attribute to put on properties. The properties that will contains this attribute will execute another method after setting a new value. For example: [MethodExecute(Log)] [MethodExecute(Save)] public string Name { get { return name; } set ...

Is there a generic attribute for all HTML elements aside from ID and class?

Like a tag that I can use to store some necessary info? But really isn’t required or used by the HTML? Works like the tag attribute for objects on Visual Basic? ...

virtual attribute problems with undefined methods

I've used Virtual attributes in the past but I can't seem to get past this, and I know the answer is probably staring me in the face. I have a model like so: model Confirmation.rb class Confirmation < ActiveRecord::Base #attr_accessible :confirmation, :confirmation_token #attr_accessible :confirmation_token def confirmation_to...

When serializing a custom generic collection to Xml how do I add an attribute to the generated collection element.

When serializing a custom generic collection to Xml how do I add an attribute to the generated collection element. Currently I have: <RootObject> <Id>1</Id> <Items> <MyCollectionItem/> <MyCollectionItem/> </Items> </RootObject> What I need is: <RootObject> <Id>1</Id> <Items Name="My collection name"> <MyCollec...

How do I make a Rails ActiveRecord dependent on an attribute?

I have created an ActiveRecord for a customer, and now they would like it so when it's destroyed, it is actually kept around for a manual rollback. What I would like to do is create a boolean attribute called 'active', and it defaults to 1. When a record is destroyed, the attribute is toggled to 0. I know I could change all my queries...

Setting value of BrowsableAttribute at runtime

I wanted to set a value of BrowsableAttribute for some of MyClass instance's properties at runtime: public class MyClass { [Browsable(true)] public int P1 { get; set } ... } Please advise how it can be done as well as how to add BrowsableAttribute to a MyClass instance's property at runtime if this attribute doesn't e...

C# AttributeUsage for Specific Class

Is it possible to have something like AttributeUsage to restrict the use of an attribute to a specific class (not just AttributeTargets.Class - that would be any class)? ...

Prevent Caching of Attributes in ASP.NET MVC, force Attribute Execution every time an Action is Executed

According to various articles (e.g. here and here) attribute results on ASP.NET MVC Actions may be cached and not executed again when a controller action is called. That behavior is not desired in my case (e.g. I have an authorization system based on my own attributes and IPs, role checks that need to execute every time, and other thing...

How can I get value of element custom attribute with Watir

I have HTML that looks like this: <input custom_attribute="so cool" type="text" /> I would like to get value of custom_attribute using Watir. ...

C#: static Guid as argument of an attribute

How can I use a static Guid as argument in an attribute? static class X { public static readonly Guid XyId = new Guid("---"); } [MyAttribute(X.XyId)] // does not work public class myClass { } It does not work because Guid must be readonly, it can not be const. The string and byte[] representation would also be readonly. Is there a...

Graphwiz: Is there a way to force a node to the bottom?

I'm building a CFG, and I'd like the exit node to always be at the bottom of the graph. Sometimes it happens naturally, sometimes it doesn't. Example: digraph G { 0; 1; 4; 5; 7; 8; 0 -> 4; 5 -> 7; 7 -> 8; 7 -> 1; 8 -> 5; 4 -> 7; } Draws (using dot): Node 1 is my exit node, I'd like that to be at the bottom....

Performance comparison of sphinx:search fulltext vs. attribute

1.How much more efficient is sphinx doing in searching fulltext than by attribute? If attribute search is much slower,for better performance,I'm gonna prefix the attribute and append to fulltext search. But when it requires range search,only attribute search can apply. 2.How to conduct attribute range search by sphinxapi in PHP? ...

How to access element with custom attribute using Watir?

I have HTML that looks like this: <input custom_attribute="so cool" type="text" /> I would like to enter text in it using Watir. ...

Problem with JSP tags - Java code as value

I have problem with JSP tags - how I can insert into attribute value in Java code? This is my code: <%! String ii = new String(); %> <% try { String id = request.getParameter("a"); int i = Integer.valueOf(id); ii = String.valueOf(i); } catch (Exception e) { response.sendError(500); }...