attributes

Why can't I directly add attributes to any python object?

I have this code: >>> >>> class G: ... def __init__(self): ... self.x = 20 ... >>> gg = G() >>> gg.x 20 >>> gg.y = 2000 and this code : >>> from datetime import datetime >>> my_obj = datetime.now() >>> my_obj.interesting = 1 *** AttributeError: 'datetime.datetime' object has no attribute 'interesting' From my python knowled...

Automatically call function #2 upon calling function #1

This should be a quick one. Is it possible to do something like this: [Callback(funtionY)] void functionX() { } void functionY() { } So that when functionX is called, functionY is called automatically too? Reason I ask is because I'm going to implement networking functionality to a small XNA based game engine, and I want to mark func...

Programatically Hide Field in PropertyGrid

Using <System.ComponentModel.TypeConverter(GetType(System.ComponentModel.ExpandableObjectConverter))> _ on the declaration of a class (which is a property of another class) that consists of a number properties. I load an instance of this class with simply ... PropertyGrid1.SelectedObject = oColumn Obviously I don't want to manuall...

Custom Attributes on Class Members

I am using a Custom Attribute to define how a class's members are mapped to properties for posting as a form post (Payment Gateway). I have the custom attribute working just fine, and am able to get the attribute by "name", but would like to get the attribute by the member itself. For example: getFieldName("name"); vs getFieldName(...

Why do optional class attributes in VB.NET have a weird syntax?

I'm just curious why class/property attributes in VB.NET have a weird optional syntax such as: <TestAttr("a", "abc", Optional1:="foo", Optional2:=3)> VB.NET allows you to set optional parameters like this to avoid order restrictions (which is lovely) but in this case it's forcing you to that. For example this is not possible: <TestA...

ObsoleteAttribute confusion

I would like to apply ObsoleteAttribute to a property, but it seems that compiler generates warnings/errors only for direct usage of attribute, any indirect usage is silently ignored. I think the following example illustrates the problem very well: using System; class Program { static void Main(string[] args) { var o = new Old(); ...

Microsoft CRM 4.0: How to set "valid for update" = 0 for attribute?

I want my attribute to be disabled if the form is in update mode. I tried to export entity xml and edit value ValidForUpdateAPI documented here but it doesn't work: when I import my customizations CRM ignore them! ...

Axis SecureSocketFactory - Setting the constructor attributes

I have a customer SecureSocketFactory set to be used by Axis when making an https connection using the following property: AxisProperties.setProperty("axis.socketSecureFactory", "com.metavante.csp.model.manager.mobilepayments.MonitiseSSLSocketFactory"); When this class is instantiated by Axis the constructor with a Hashtable (attributes...

How can I get arrays to have a name other than "Items" when generating C# code from an XSD schema?

I'm working on a project that has to connect to some ancient webservices that pack some hierarchical data for requests and responses into single strings of hierarchical XML. I've been using xsd.exe to generate XSDs from sample request and response XML fragments, modifying them where necessary to be the best possible definition, and usi...

How can I access a method's parameter from an associated attribute?

Hi. Given the following classes, how can i intercept Class1.SampleMethod's Value from SampleAttribute? Thanks Public Class Class1 <SampleAttribute()> _ Public Function SampleMethod(ByVal Value As Integer) As Boolean Return True End Function End Class <AttributeUsage(AttributeTargets.Method)> _ Public Class SampleAtt...

How to whitelist just some attributes with HTMLpurifier?

How to whitelist just some attributes with HTMLpurifier? I want HTMLpurifier to delete all the other, not allowed attributes. ...

Can I find out if a particular attribute was present on the calling function?

Is there a way to find out if the calling function had attributes set on it? [RunOnPlatformB] int blah() { return boo(); } int boo() { // can i find out if RunOnPlatformB was set on my caller? } ...

Intercepting changes of attributes in classes within a class - Python

I have been messing around with pygame and python and I want to be able to call a function when an attribute of my class has changed. My current solution being: class ExampleClass(parentClass): def __init__(self): self.rect = pygame.rect.Rect(0,0,100,100) def __setattr__(self, name, value): parentClass.__setattr__(sel...

NHibernate Fluent vs. Attributes

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes? I have some experience with Java Hibernate annotations, which I liked, but I'm curious if the NHibernate attribu...

jQuery maxlength attribute problem with textareas

With jQuery version 1.2.3 I'm trying to add nodes after textarea elements with attribute 'maxlength' but it doesn't work: $("textarea[@maxlength]").after("<b>Aint working</b>"); This is the HTML code: <textarea maxlength="500">This is a test.</textarea> <textarea maxlength="250">Yet another line.</textarea> <textarea maxlength="125"...

Are there attributes in C# for affecting how Intellisense displays class members?

Are there any C# attributes that I can apply to class members, to change the way they appear in the Intellisense listings? This popped into my head when I was building a class with many static constants, and I (briefly!) wanted it to look like an enumeration in Intellisense. Yes, that's silly. But it got me thinking - is there any way ...

How do you access a custom XHTML attribute with JavaScript?

I have the following XHTML: <span id="myid" cus:att="myvalue" xmlns:cus="http://mycompany.com/customnamespace"&gt; </span> Is it possible to access custom attributes with javascript? I have the element that represents the span. Doing myElement.att doesn't work, and I can't figure out how to specify the namespace? ...

XPath 1 query and attributes name

First question: is there any way to get the name of a node's attributes? <node attribute1="value1" attribute2="value2" /> Second question: is there a way to get attributes and values as value pairs? The situation is the following: <node attribute1="10" attribute2="0" /> I want to get all attributes where value>0 and this way: "attr...

How to access the Description attribute on either a property or a const in C#?

How do you access the Description property on either a const or a property, i.e., public static class Group { [Description( "Specified parent-child relationship already exists." )] public const int ParentChildRelationshipExists = 1; [Description( "User is already a member of the group." )] public const int UserExistsIn...

How can I transform an element attribute to an element name in XSLT?

I'd link to transform XML with attributes like the 'name' attribute in the following: <books> <book name="TheBumperBookOfXMLProgramming"/> <book name="XsltForDummies"/> </books> into elements called what was in the name attribute: <books> <TheBumperBookOfXMLProgramming/> <XsltForDummies/> </books> using XSLT. Any ideas? ...