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...
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...
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...
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?
...
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...
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...
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...
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...
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...
Can you give me an example?
...
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 ...
Hi,
What is the most innovative usage of C# attributes you've implemented or have seen implemented?
...
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...
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...
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...
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.
...
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
...
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...
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
...
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...