attributes

C# Attribute to modify methods

Hello, all. Maybe i've not googled enough, but i can't find any example on this question. It is possible in C# to create an custom attribute which, applied to a class, modifies all of its methods? For example, adds Console.WriteLine("Hello, i'm modified method"); as a first line (or it's IL equivalent if it's done at runtime)? ...

Xpath - How to select parent based on attribute of child?

How do you select a parent based on the attribute of a child? I want to select a div: //*[@id='outer']/div/div/div/div that has a child with the 'a href' attribute equal to 'www.blah.com': //*[@id='outer']/div/div/div/div/a[@href='www.blah.com'] ...

is there any property default value initializer attribute?

I need like this public class AA{ public AA(){} [Default("hi")] public string value1{get;set} [Default(12)] public int value2{get;set;} } Usage: AA a=new AA(); print(a.value1); //result: hi print(a.value2); //result: 12 Is it possible to create like this? I know another way Public class AA{ public AA(){value1=...

NHibernate Attributes Mapping List

Hello, I'm a new NHibernate developer. I'm using attributes and not map files and I have configured the application to create the tables automatically. I Have two classes , Group and User. Withing the Group class I have a list of users public class Group { [NHibernate.Mapping.Attributes.Id(Name = "GroupId")] [NHibernate.Mapp...

Tell Actions/Controllers to Persist TempData

I understand that TempData is designed to work only between a single page request. But I think have a situation I think breaks the intended functionality. I use Controllers in preference to Handlers for delivering images. I don't now if that is best practice, but it works very well for me. The problem though, is that each call to one of...

SQL Server 'object'/'property' relational tables linking to other tables

Excuse the poor title, i can not think of the correct term. I have a database structure that represents objects, objects have types and properties. Only certain properties are available to certain types. i.e. Types - House, Car Properties - Colour, Speed, Address Objects of type car can have both colour and speed properties, b...

mass_assign, virtuell attributes, nested tables, attr_accessible, accepts_nested_attributes_for, action=>update

Hello, I don't understand the workaround with the virtuell attribute. Form Railsforum by Duplex URL: http://railsforum.com/viewtopic.php?pid=110698#p110698 His solution: > def type_helper self.type end def type_helper=(type) self.type = type end < My application is based on RailsCast part 73,74,75 complex_forms I have two models...

Datastructure alignment.

So, I'm coding some packet structures (Ethernet, IP, etc) and noticed that some of them are followed by attribute((packed)) which prevents the gcc compiler from attempting to add padding to them. This makes sense, because these structures are supposed to go onto the wire. But then, I counted the words: struct ether_header { u_int8_t...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() { throw new ArgumentException("BBB"); } I would Like to have the test pass if the message in the exception is BBB , but fail if it i...

ASP.NET - Dynamically added button contains extra value property

So, I'm trying to dynamically add a button to a site to give the user of an idea of what they are adding to a form. However, when it renders a new button, it keeps providing the value property as "" and ignoring the attribute that I add. I've attempted to fix this to no avail, including removing the value attribute before adding in my ve...

How to remove "onclick" with JQuery?

php code: <a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> How to remove onclick="check($id,1) so "Qualify" can not be clicked or "check($id,1) won't be fired. How to do it with JQuery? ...

CSS and targeting: img "title=this thing here" attribute

Dear Stack Can CSS be used to change the title attribute in this img tag to something more pleasant than P10305...? All the images I need to target are in tables (as shown below) I would like to change all image title attribute in a website to the name of the company. Is it possible? <td><img border="0" title="THIS THING HERE" src="h...

asp.net MVC confused by custom attributes creation

hi i am trying to create a custom attribute for my MVC application so that i can call [CheckLogin] this is to check my cookie as i am not using forms authentification. i have created a class CheckLogin and this is in my App_Code folder and the code is as follows: using System.Web.Mvc; using System.Attributes; using System.Diagnos...

Using method attributes to eliminate redundant code

I have the following method which prints lines to the console. public void MyMethod() { try { Console.WriteLine("Hello!"); Console.WriteLine("My name is MyMethod"); } finally { Console.WriteLine("Bye."); } } I have a few of these methods and they all do the same thing (i.e. try { "Hello"; Someth...

Naming "class" and "id" HTML attributes - dashes vs. underlines

<div id="example-value"> or <div id="example_value">? This site and Twitter use the first style. Facebook and Vimeo - the second. Which one do you use and why? ...

Verify if all attribute type xs:ID are present in the XML

I've made an XSD that contains this complex Type "Text" : <xs:complexType name="Text"> <xs:complexContent mixed="false"> <xs:attribute name="Id" type="xs:ID" use="required"> </xs:attribute> </xs:complexContent> </xs:complexType> In a string, I want to find all the Text nodes that are missing the ID. Is there a way to vali...

Hibernate entity with user defined attributes

Can someone please give me some tips on modeling hibernate entities that have some known attributes while the majority are defined by the user of the system (during initial setup of the system) I need to be able to search on these user defined attributes at a later point in time. ...

FilterAttribute Order not working

I have 2 attributes that I use within the controllers of my MVC application. AttributeA extends System.Web.Mvc.AuthorizeAttribute and AttributeB extends System.Web.Mvc.ActionFilterAttribute. I want AttributeB to always be run first. I have tried all possible combinations of Order based on this article, but AttributeA is always run befor...

Performance overhead of using attributes in .NET

1.. Is there any performance overhead caused by the usage of attributes? Think for a class like: public class MyClass { int Count {get;set;} } where it has 10 attibutes (attributes being classes, where the attribute classes themselves are way larger than MyClass itself like: public class FirstAttribute : Attribute ...

What's the reason for not being able to use static methods, instance methods, etc as a argument to an attribute in .NET?

What's the reason for not being able to use static methods, instance methods, etc as a argument to an attribute in .NET? Why doesn't C# allow this? ...