attributes

How do you model c# attributes in UML?

I want to model c# class attributes and variable attributes (not UML attributes) in UML and am not sure how to do it. [AttributeForTheClass] class SomeClass { [AttributeForTheField] int SomeField; [AttributeForTheMethod] int SomeMethod( [AttributeForTheParameter]int someParam) { ... } } How do you mo...

Versatile xml attribute regex with javascript

Basically I have an xml document and the only thing I know about the document is an attribute name. Given that information, I have to find out if that attribute name exists, and if it does exist I need to know the attribute value. for example: <xmlroot> <ping zipcode="94588" appincome = "1750" ssn="987654321" sourceid="XX9999" sourc...

How to add/update an attribute to an HTML element using javascript?

I'm trying to find a way that will add / update attribute using javascript. I know I can do it with SetAttribute function but that doesn't work in IE. ...

Is it legal to create your own CSS attributes?

I'm working on a windowing application for a website of mine. Right now, I have each individual window set up as a in the body of the site. I add new windows by literally adding the appropriate code to the end of the body element, and delete them by removing that div. (I'm using jQuery for the underlying JavaScript architecture.) I've ...

Class attribute declaration: private vs public.

What are the advantages of defining a private attribute instead of a public attribute? Why should I have the extra work of creating methods to access and modify privates attributes if I can just make them public? ...

Set DataContract's DataMember attributes during runtime?

Hello there, is it possible to dynamically set the datacontract's datamember attributes during runtime? Basically what I need is to read in serialized instances of a class which contained the DataMemeber attributes on two properties at the time of serialization, but the current 'version' does not longer have them but I need to migrate t...

Grant private access attribute

What's the name of the attribute that you apply on an assembly to allow access from another assembly to private methods? Thanks! ...

Attributes in C#

I know that C# (and .NET in general) is big on attributes. However, despite the fact I have programmed in C# for many years, I haven't found myself ever using them. Would someone get me started on them, and explain where is the best to use them? Thanks ...

How to control method behavior via an attribute?

I would like to apply a custom attribute to some methods that indicates they should be handled as a transaction. In general, I know how to create custom attributes by inheriting from System.Attribute, but I don't know how to do what I need. My goal is something like this: [TransactionalMethod()] public void SaveData(object someObject)...

How can I add an attribute to a return value in C++/CLI?

In C#, you can decorate function return values with attributes, as follows: [return: MarshalAs(UnmanagedType.IUnknown)] object LoadStuff(); My question is, how can I do this in C++/CLI? I have this: [return: MarshalAs(UnmanagedType::IUnknown)] Object^ LoadStuff(); but the compiler is erroring with 'return' : unknown attribute quali...

Can I use Description Attribute to assign label text?

In a DTO object I'd like to hard code the label description for the rendered html text box so that I can have an html helper function like TextBoxWithLabel where I pass only the object and it automatically creates the label taken from the description attributes. public class MessageDTO { public int id { get; set; } [Descriptio...

Passing a method to another method

Is it somehow possible to send a function to another function for it to run. For instance...I want to have an attribute on a field where I can specify a method that will be sent to another method where the method passed in will be run. Not sure if that makes any sense but here's a small example. [ValidateIf(x=>x.test())] public string ...

attributes not found by jquery attribute selector

I need to reask my old question, I probably shouldnt have asked it at 1am :P It seems that some attributes are not being found using jquery's attribute selector: $("*[some=value]"); So far it seems that i cant use form's action attribute, and img's src attribute. Is there a list somewhere of attributes that do not work so i can write...

What does ReliabilityContractAttribute do?

Does it do anything at all or it is only for documentation. If it is only for documentation, why documentation doesn't document it? For example these are two methods from System.Array class: [ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)] public static void Copy(Array sourceArray, Array destinationArray, int length) ...

Get an object attributes list in Objective-C

How can I get a list (in the form of an NSArray or NSDictionary) of a given object attributes in Objective-C? Imagine the following scenario: I have defined a parent class which just extends NSObject, that holds an NSString, a BOOL and an NSData object as attributes. Then I have several classes which extend this parent class, adding a...

ReadOnlyAttribute vs PropertyDescriptor.IsReadOnly()

What is the difference between using a PropertyDescriptor that returns a value for the IsReadOnly() method, and one that is associated with a ReadOnlyAttribute? ...

Do you think C# attributes (or similar mechanisms) are a good idea or do you discourage the use of them?

I have based many designs and frameworks that use C# Attributes over the past 4 or 5 years. But lately I see many people openingly discouraging their use or changing their frameworks to reduce the need or use of them. I found them to be a godsend but now I am starting to wonder what I am missing. To clarify: Use Convention over Conf...

Attributes vs comments

What advantages do attributes have over the use of comments (or xml comments at the signature level)? I do remember seeing a thread in the C# section of this site somewhere, but I can't find it now. Also, is it possible to apply an attribute to a specific parameter in a method (this was an interview question I read somewhere)? ...

Adding an ArrayList into a class - what does it do?

Hi Following on from this Q of mine: http://stackoverflow.com/questions/754184/whats-the-best-way-to-make-this-java-program I was recommended to store a list in Lecturer class and Course class. So I did, and it looks something like this: public class Lecturer { private String id; private String name; List<Course> cours...

Meaning of text between square brackets

Hi, I have seen a lot of C# programs that use the [], for example [STAThread] and then the code follows another classic example is [DLLImport]. I know what STATThread means but my question is what is the significance of the square brackets, essentially what do they tell the compiler. Many Thanks ...