attributes

Design question - using an event, attribute, or not? (mvc)

I'd like to know what you think of the following design options. I have an 'AgendaController' (.NET MVC project) which handles user actions like viewing their agenda, making appointments, etcetera. When a user makes an appointment, the appointment is saved in a database. Then, there is a 'secondary' task that has to be done, in this cas...

I want to use javascript to insert an attribute to an element

Hi all Any ideas how I would go about writing a javascript method to insert an attribute to a tag eg. I have <input id='in1' value='Submit' type='submit'/> and I want to insert an attribute name <input id='in1' name='submit_content' value='Submit' type='submit'/> Thanks ...

How to map a many-to-many linking table to use another schema?

I have a few classes that I map to non-default schema using NHibernate.Mapping.Attributes like this: [Class(Lazy = true, Schema = "NonDefaultSchemaName")] public class Class1 I also have some many-to-many mappings: [Set(Inverse = false, Table = "Class1ToClass2", Lazy = true, Cascade = "none")] [Key(1, Column = "Class1ID")] [ManyToMan...

Is there a way to pass (or access) a controller's ModelState to an ActionFilterAttribute?

I have a custom validation attribute derived from action filter attribute. Currently the attribute simply sets an ActionParameter value indicating if the item validated was good or not and then the action has to have logic to determine what to do with information. public class SpecialValidatorAttribute: ActionFilterAttribute { p...

Internationalization and C# method attributes?

I'm working on some SharePoint web parts and I'm trying to make them as locale-independent as possible. I've got all most text in resource files, and I'm looking at the attributes on my Web Part: [WebBrowsable(true), Category("My Category"), WebDisplayName("Display Name here"), WebDescription("Tells you all about it"), Personalizable(Pe...

NUnit Test Run Order

Hi, By default nunit tests run alphabetically. Does anyone know of any way to set the execution order? Does an attribute exist for this? Any help would be greatly appreciated. Thanks Zaps ...

descriptive div to my links

I'm trying to add a extra descriptive div to my links. The div should get it's information from the li a title attribute. I'm able to get the title attribute but how do I pass it on to the div .omschrijving? $("#sidebar li ").append("<div class='omschrijving'></div>"); $("#sidebar li a").each(function(){ var hoverText = $(this).at...

Localization of attribute values in .NET

How can I localize/internationalize attribute values in .NET? My specific example is for ASP.NET web parts such as WebDisplayName, WebDescription, etc. where I inherit from the base class that uses these attributes. Also, is there any difference to doing this with attributes declared in my own classes? Thanks! ...

C#: Attrbute for intellisense to show method only outside of assembly.

Basically what I'm hoping for is something that would work like how the Obsolete attribute works with Intellisense and strikes the method text when typing out the name. What I'm looking for is an attribute that blocks the method from being seen with the assembly it's defined. Kind of like an reverse internal. Using 3.5 by the by. Yea...

How do I retrieve specific attributes of a relationship/collection?

Hi All, Is there a good way to retrieve all of a specific attribute from a relationship/collection? For instance, I want a list of all the names of a person's cars. Obviously I can't do the following: Person.Cars.Name(s) ...but does something of that nature exist in ruby (or is there an ActiveRecord helper method) that handles that?...

How do I "fake" C# style attributes in Ruby?

EDIT: I slightly changed the spec, to better match what I imagined this to do. Well, I don't really want to fake C# attributes, I want to one-up-them and support AOP as well. Given the program: class Object def Object.profile # magic code here end end class Foo # This is the fake attribute, it profiles a single method....

Is there an Attribute I can use on a property to tell DataGridView how to format the column?

Following on a bit from this question, if I have this class: private class MyClass { [DisplayName("Foo/Bar")] public string FooBar { get; private set; } public decimal Baz { get; private set; } } And I want to display a List<MyClass> in a DataGridView (with autogenerated columns), what's the easiest way to make the Baz column di...

Asp.NET MVC: Practices questions

1) Isn't it a bad practice to use these attributes on all of my Controllers? [HandleError] [CompressFilter(Order = 1)] Compress filter is defined as: public class CompressFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if ( !AppConfig.IsResponseCompressionEnabled ) {...

Emulate the .NET [Obsolete] Attribute

Possible Duplicate: Custom Compiler Warnings Duplicate: http://stackoverflow.com/questions/154109/custom-compiler-warnings/154254 I'm new to writing my own Attributes for .NET, but would like to write one that behaves similarly to the System.ObsoleteAttribute attribute--if a class/member is tagged with the attribute I would...

How to test if a class attribute is an instance method.

In Python I need to efficiently and generically test whether an attribute of a class is an instance method. The inputs to the call would be the name of the attribute being checked (a string) and an object. hasattr returns true regardless of whether the attribute is an instance method or not. Any suggestions? For example: class Test...

C# Dynamic Attribute Arguments

Is there a way to do the following? I see that the Attribute Arguments must be a constant expression, so how would I work around this? If I dont want to load some properties into a datagridview using binding, whats the next best alternative? class TestObj { private bool isBrowsable = false; [Browsable(isBrowsable)] ...

Should I use Elements or Attributes in XML?

Hello I am learning XML from W3schools. Here: hXXp://www.w3schools.com/xml/xml_attributes.asp The author mentions the following: XML Elements vs. Attributes <person sex="female"> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> <person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith<...

Check existence of an attribute with JQuery

I have a colection of checkboxes with generated ids and for a reason, some have an extra attribute. Is possible using JQuery to check if an element has a specific attribut ? For example can I verify if the following element has as attribute "myattr" ? The value of the attribute can vary. <input type="checkbox" id="A" myattr="val_attr">A...

What does this .NET attribute do?

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] I saw this attribute in the reflector for the base class libraries in .NET. Maybe immutable guarantees are supported internally? ...

Restricting Attribute usages only for Public and Protected Variables c#

Hi Is it possible to restrict an attribute usage to just protected and public variables. I just want to restrict to private variables. ...