attributes

frameset - swap columns with rows using javascript.

Hey everyone, I have a frameset with it's cols attribute set to "50%,50%" at the moment. I have a toggleView method which is called after a click on an element. What I aim to do is to change frameset from displaying cols to rows, again divided 50/50. I have attempted to perform a removeAttribute("cols") on the frameset, while this doe...

Why does C# forbid generic attribute types?

This causes a compile-time exception: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>] public static class StringValidation { } I realize C# does not support generic attributes. However, after much Googling, I can't seem to find the reason. Does anyone know why generic types cannot derive from Attribut...

C++0x Attributes you'd like to see

Recently voted into the C++0x working paper was an attribute syntax. This syntax provides a way to specify other pieces of information to the compiler. The Committee Draft also includes several standard attributes. The syntax is to wrap the attribute list in double square brackets, e.g. [[noreturn]]. These attributes can be "namespaced"...

VS 05 - Designer Attributes and Component Designer. How are they related?

I had this answer on another post I asked: "I believe the VS designer does it [components of a menustrip/statusstrip] by getting an instance of the control's designer (see the Designer attribute), and, if the designer is a ComponentDesigner, getting the AssociatedComponents property." How do I do this? I'm not even sure where to begin....

Problems finding an attribute attached to a Type

When running the below code a type is never returned, despite there being a class with the correct attribute assigned. In fact the attr array always has a length of 0. Assembly a = Assembly.LoadFile(file); foreach (Type t in a.GetTypes()) { object[] attr = t.GetCustomAttributes(typeof(SchemeNameAttribute), false); foreach (obje...

Can I add an attribute to a function to prevent reentry?

At the moment, I have some functions which look like this: private bool inFunction1 = false; public void function1() { if (inFunction1) return; inFunction1 = true; // do stuff which might cause function1 to get called ... inFunction1 = false; } I'd like to be able to declare them like this: [NoReEntry] public vo...

Custom Attributes and Exceptions in .net

Hi, while writing a custom attribute in C# i was wondering if there are any guidelines or best practices regarding exceptions in attributes. Should the attribute check the given parameters for validity? Or is this the task of the user of the property? In a simple test I did the exception was not thrown until i used GetCustomAttributes ...

Is there an inverse of System.Diagnostics.ConditionalAttribute?

Is there an analogous conditional-not-present attribute or maybe a way to use the Conditional attribute to only include a method if that symbol is not defined? What I'm looking for is something that works like this: [Conditional("!SILVERLIGHT")] private void DoStuffThatSilverlightCant() {...} Such that the method will not be included...

Mocking attributes - C#

I use custom Attributes in a project and I would like to integrate them in my unit-tests. Now I use Rhino Mocks to create my mocks but I don't see a way to add my attributes (and there parameters) to them. Did I miss something, or is it not possible? Other mocking framework? Or do I have to create dummy implementations with my attribut...

How do I run robocopy without copying extended attribute information?

Greetings, I've got a bat script which copies certain information from a computer onto a USB hard drive using Robocopy. The hard drive is FAT formatted and therefore doesn't support directories with extended attributes, leading me to robocopy error 282 as described here. How do I tell robocopy to copy all the attribute information EXC...

How do I take a GUID as an attribute parameter?

I need a Guid property in some attribute class like this: public class SomeAttribute : Attribute { private Guid foreignIdentificator; public Guid ForeignIdentificator { get { return this.foreignIdentificator; } set { this.foreignIdentificator = value; } } } But in attribute definition I can use only primiti...

Obsolete attribute causes property to be ignored by XmlSerialization

I'm refactoring some objects that are serialized to XML but need to keep a few properties for backwards compatability, I've got a method that converts the old object into the new one for me and nulls the obsolete property. I want to use the Obsolete attribute to tell other developers not to use this property but it is causing the propert...

Python function attributes - uses and abuses

Not many are aware of this feature, but Python's functions (and methods) can have attributes. Behold: >>> def foo(x): ... pass ... >>> foo.score = 10 >>> dir(foo) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce_...

Find through multiple attributes in XML

Hello, I'm trying to search multiple attributes in XML : <APIS> <API Key="00001"> <field Username="username1" UserPassword="password1" FileName="Filename1.xml"/> <field Username="username2" UserPassword="password2" FileName="Filename2.xml"/> <field Username="username3" UserPassword="password3" FileName="Filename3.xml"/...

A get() like method for checking for python attributes

If i had a dictionary 'dict' and I wanted to check for dict['key'] I could either do so in a try block (bleh!) or use the get() method, with False as a default value. I'd like to do the same thing for object.attribute. That is, I already have object to return False if it hasn't been set, but then that gives me errors like AttributeErro...

Localization of DisplayNameAttribute

Hi, I am looking for a way to localize properties names displayed in a PropertyGrid. The property's name may be "overriden" using the DisplayNameAttribute attribute. Unfortunately attributes can not have non constant expressions. So I can not use strongly typed resources such as: class Foo { [DisplayAttribute(Resources.MyPropertyNa...

How can I force the PropertyGrid to show a custom dialog for a specific property?

I have a class with a string property, having both a getter and a setter, that is often so long that the PropertyGrid truncates the string value. How can I force the PropertyGrid to show an ellipsis and then launch a dialog that contains a multiline textbox for easy editing of the property? I know I probably have to set some kind of attr...

How can I add attributes to methods and types defined in IronPython?

Since IronPython doesn't support attributes I am wondering if there is another way to decorate IronPython classes with attributes, perhaps with reflection? ...

How do I add a name.value to the header when generating a soap message from ruby with soap4r

I've created a driver from wsdl When I invoke my request, I would like the header to contain an element, i.e, I want to see something like the following: REPLACE_WITH_ACTUAL blah blah blah However, looking around, everyone talks about subclassing SOAP::Header::SimpleHandler and then injecting an instance into t...

Xpath query to select node when attribute does not exist?

I want to select nodes for which a specific attribute does not exist. I've tried the Not() function, but it doesn't work. Is there a way for this? Example: The following Xpath query: group/msg[not(@owner)] Should retrieve the first node but not the 2nd one. However, both SketchPath (tool to test Xpath queries) and my C# code consider...