attributes

Is there a standard "never returns" attribute for C# functions ?

I have one method that looks like this: void throwException(string msg) { throw new MyException(msg); } Now if I write int foo(int x, y) { if (y == 0) throwException("Doh!"); else return x/y; } the compiler will complain about foo that "not all paths return a value". Is there an attribute I can add to t...

.NET: Strongly-typed HTML "id" attribute

Is there any object in the .NET framework that will sanitize a string so that it is safe to use as the "id" attribute value for an HTML tag? ...

How to determine if user account is enabled or disabled

I am throwing together a quick C# win forms app to help resolve a repetitive clerical job. I have performed a search in AD for all user accounts and am adding them to a list view with check boxes. I would like to default the listviewitems' default check state to depend upon the enabled/disabled state of the account. string path = "LDA...

C# Xml serialization - disable rendering root element of array

hi, can i someway disable rendering of root element of collection? this class with serialization attibutes [XmlRoot(ElementName="SHOPITEM", Namespace="")] public class ShopItem { [XmlElement("PRODUCTNAME")] public string ProductName { get; set; } [XmlArrayItem("VARIANT")] public List<Sho...

How to NUnit test for a method's attribute existance

public interface IMyServer { [OperationContract] [DynamicResponseType] [WebGet(UriTemplate = "info")] string ServerInfo(); } How do I write an NUnit test to prove that the C# interface method has the [DynamicResponseType] attribute set on it? ...

Xstream: removing class attribute

How do I remove the class=”Something ” attributes in Xstream . I use Xstream with annotations ...

Jquery ajax issue with radio button list

<input type='radio' name='rbTemplateList' id='template1" value=1 > <input type='radio' name='rbTemplateList' id='template3" value=3 > <input type='radio' name='rbTemplateList' id='template5" value=5 > <input type='radio' name='rbTemplateList' id='template7" value=7 > I want to onclick one of the rbTemplateList, will raise a...

Attribute querying not casting to base type of attribute, what gives?!?

I'm trying to query attributes and access the base type of several attributes. For some reason it is failing to cast properly and not executing as expected. Here is the code below: internal static void ValidateProperties(TModel model, ModelStateDictionary modelState) { Type type = model.GetType(); Pr...

Is it possible to adorn a LINE OF CODE with a Conditional Attribute? (or something similar)

Hi! I plan to put a call to MethodBase.GetCurrentMethod() at the beginning of most methods (for informative logging), but since this would present a high overhead, it would be good if a conditional attribute could be used used like: #define LogMethodNames where... [Conditional("LogMethodNames")] was put above every line call GetCu...

Allow or disallow method run in .NET

Hi! I need to organize some simple security in a class depends on value of the enum. All that I can figure out is using attribute on a method and then run check then if it fails throw an exception. Sample: [ModulePermission(PermissonFlags.Create)] public void CreateNew() { CheckPermission(); System.Windows.Fo...

How can I assign many Moose attributes at the same time?

I'm gradually Moose-ifying some code that reads lines from a pipe delimited, splits each and assigns adds them to a hash using a hash slice. I've turned the hash into a Moose class but now I have no idea how to quickly assign the fields from the file to the attributes of the class (if at all). I know I can quite easily just do: my $li...

Parsing XML, details and attributes, iphone

I'm not sure about parsing an xml with attributes. have seen a similar question here But it shows to get an attribute of intValue. But i need to get the attributes of string type,How to do that?? Images of xml and the relevant portions are given in the following links Click here for xml and here for required data ...

XSLT Transformation issue - how to populate attribute

Hello All, I am using xslt first time. I have to create an element based on some criteria. here is i/p xml: <FirstUser> <User id="2" description="ABC" Type="HR"/> </FirstUser> <SecondUser> <User id="3" description="ABC" Type="HR"/> <User id="4" description="xyz" Type="Admin"/> <User id="5" description="LMN" Type="Payroll"/> </...

Custom model attribute (column name) title in Ruby on Rails

Can I add custom model attribute titles, so forms could automatically render them instead of "prettied" column name? For example I apply some method in my model, which defines attribute title: imaginary_method_which_defines_attribute_title :description, "Aprašymas" So I do not need to write title in every form label helper: <%= f.la...

Are there any tools for consolidating a whole bunch of style tags into classes?

Example: Say for instance you had the following two tags some where in a legacy page you've been assigned to work on: <table style="padding:0px; margin:0px; border: 0px; width:100%;"> <td style="width:100%; margin:0px; padding:0px; border: 0px;"> Would there be a program that could make a list of these random style tags and...

Adding Editor / EditorAttribute at Run-time (Dynamically) to an Object's Property

How to add the EditorAttribute (Editor) to an object's property at run-time? I have My.Settings.ExcludeFiles, which is created by the settings designer as Public Property ExcludedFiles() As Global.System.Collections.Specialized.StringCollection. When editing ExcludedFiles via a property grid, the "String Collection Editor" generates a "...

AS3 XML, nodeName with attributes comes up blank

I've tried many different ways of accessing the name of an attribute, but just can't get it working. The current Function: protected function applyProperties(_axml:XML):void { var list:XMLList = _axml.properties; var list2:XMLList = list.attributes(); for( var i = 0; i < list2.length(); i++ ){ trace(list2[i].nodeName.toStr...

Get all Attributes from a HTML element with Javascript/jQuery

Hi I want to put all attributes in a Html element into an array: like i have a jQuery Object, whichs html looks like this: <span name="test" message="test2"></span> now one way is to use the xml parser described here, but then i need to know how to get the html code of my object. the other way is to make it with jquery, but how? the...

.Net adding Min\Max lenght to field attribute?

Hello and thanks for any assistance. I have a WCF project that contains a Customer class object. Currently, I use svcutil to generate the WSDL and XSD's that I give to the client. When the XSD's are generated they are pretty simple. For some of the fields I want to add Min and Max Length Attributes, so that the XSD has the <xs...

c# Attributes and overriding behavior asp.net mvc

I have a transaction attribute that performs a commit in the onactionexecuted method. This is specified at the controller method, for one of my actions i need to override that method and not call the code in onactionexecuted? Here is some sample code. [Transaction] public class TestController { public ActionResult Index() { ...