attributes

Why does my .NET Attribute not perform an action?

Hi, I've created a simple Attribute: [AttributeUsage(AttributeTargets.Method)] public class InitAttribute : System.Attribute { public InitAttribute() { Console.WriteLine("Works!"); } } and I apply it to a simple method: static class Logger { public static string _severity; public static void Init(string s...

Postsharp: how does it work?

Following the advice got on another question of mine, I converted the code there quoted to be used with PostSharp: Attribute: [Serializable] public sealed class InitAttribute : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionEventArgs eventArgs) { Console.Write("Works!"); } } static class Logg...

Passing dynamic attributes between JSP tags?

I have a set of JSP tags that use dynamic-attributes to allow for arbitrary HTML attributes to be passed in to them, like this: <%-- tag named a:div --%> <%@ tag dynamic-attributes="attrs" %> <div <c:forEach var="attr" items="${attrs}"> ${attr.key}="${attr.value}"</c:foreach>> </div> I then have another tag that I want to be able to p...

(.net) When is an attribute's constructor run?

When is it run? Does it run for each object to which I apply it, or just once? Can it do anything, or its actions are restricted? ...

c# execute code inside custom attribute

Possible Duplicate: Why does my .NET Attribute not perform an action? Hi, This may soundlike a very dumb question and I don't know what is possible here as all the "custom attribute" tutorials on the net are pretty much the same and they don't address what I want to do. I've seen some code out there where code is written inside...

HttpClient request set Attribute question

Hi I play for a while (couple of weeks) with this HttpClient lib. I want somehow to set Attribute to the request. Not parameter but Attribute. In my servlet I want to use Integer inte = (Integer)request.getAttribute("obj"); I have no idea what i miss. i try this. NameValuePair[] pair = new NameValuePair[1]; pair[0] = new NameValuePair...

jQuery attribute question

I'm trying to select a series of divs one at a time. I'm sure theres a better way to do this, but I gave them all unique rels and I'm using the rels to select them one at a time. I want to move them over the width of the div, then animate it dropping down the screen. What I have is: $(document).ready(function(){ var totalbricks = 7...

Specify required base class for .NET attribute targets

I tried to create a custom .NET attribute with the code below but accidentally left off the subclass. This generated an easily-fixed compiler error shown in the comment. // results in compiler error CS0641: Attribute 'AttributeUsage' is // only valid on classes derived from System.Attribute [AttributeUsage(AttributeTargets.Class)] int...

XSLT on SSRS report

I want to translate an XML file with data like the following: <FlatData> <Details1_Collection> <Details1 Customer1="Customer" Total1="3" /> ... </Details1_Collection> </FlatData> The data I am interested in is the attributes and their values in each Details1. The problem is that these attributes are not necess...

What is the difference between Methods and Attributes in Ruby?

Can you give me an example? ...

Writing Custom Attribute in C# like ASP.Net MVC Authorize attribute

Hi, I like ASP.Net MVC Authorize attribute, I can extend it and build my own logic and decorate my controller with it. BUT, In my architecture, I have one common service layer(C# Class Library). End user can access my application via ASP.Net MVC web site or via my exposed REST WCF Webservice layer. My asp.net MVC application and REST ...

Most innovative usage of C# attributes

Hi, What is the most innovative usage of C# attributes you've implemented or have seen implemented? ...

For-each inside another For-Each and access a attribute defined in the first loop using the value of the second

For-each of a collection of headers and find a certain attribute in another collection of Items. If I have something like: <ROOT> <Listings> <Listing> <Headers> <Header width="3cm" value="UserName" /> <Header width="3cm" value="MobileAlias" /> <Header width="3cm" value="Name" /> <Header wid...

Why doesn't __attribute__((constructor)) work in a static library?

In the following example, the program should print "foo called": // foo.c #include <stdio.h> __attribute__((constructor)) void foo() { printf("foo called\n"); } // main.c int main() { return 0; } If the program is compiled like this, it works: gcc -o test main.c foo.c However, if foo.c is compiled into a static library, t...

Asp MVC [Authorize] to return a Post instead of a Get

I would like to use [Authorize(Roles="Admin")] tags on my controller methods. If a user is not an admin I would like to return this user to my login screen. The default behaviour of returning the user to my login page is reroute my user to "Account/Login" using a Get url. The problem is, my website's subpages are all partial views refr...

Will there be generic attributes in C# 4?

So - if there isn't particular reason why there isn't generic attributes, I'm wondering - maybe they will be implemented? Those would be great for ASP.NET MVC action filters. ...

Looking for good tutorials / documents for Postsharp laos, understanding of "Librarian" samples.

Hi, Can anyone point me to good learning material on PostSharp / laos plugin. I liked the "Librarian" sample shipped with Postsharp, it does cover lots of stuff, but is difficult to understand. Is there any explanation / writeup on samples too? Thanks & Regards, Ajay ...

Manually parse string as XAML Attribute

How does the XAML Parser convert the string "Red" in Foreground="Red" to a SolidColorBrush? Allthough I know the Types have System.ComponentModel.TypeConverter defined, I doupt that the WPF XAML parser acutally always uses those to convert the string to the brush. Are there any XAML APIs apart from XamlReader.Load (wich wants a valid xml...

Is it possible to override an attribute which has been applied at controller level on a specific method?

Hi, If I've applied an authorisation attribute at controller level, is it possible to override this on one of the methods on that controller? Thanks James ...

Ruby on Rails : Cannot access an object's attributes in an array

Hello, I am building a site with works and their credits. What I am trying o achieve is to find each work's similar works based on the mutual titles in their credits. I am adding each similar work into an array in a for loop and when I try to access the attributes of these works I get a "nil object when you didn't expect it!" error. I...