How can attribute's code know what type it's applied to?
public class SomeAttr: Attribute { void Method() { //here I want to know the type this instance of attribute is applied to } } Thanks!! ...
public class SomeAttr: Attribute { void Method() { //here I want to know the type this instance of attribute is applied to } } Thanks!! ...
I am aware of ActiveRecord::Dirty and the related methods, but I don't see a means by which I can subscribe to an attribute changed event. Something like: class Person < ActiveRecord::Base def attribute_changed(attribute_name, old_value, new_value) end #or attribute_changed do |attribute_name, old_value, new_value| end end ...
What is the syntax to use the [TestDescriptionAttribute][1] of a test to populate the Description column in the Test Results window? Context: Visual Studio 2008 Team System I've read the documentation, but am not able to find a concrete example. Based, loosely, on Ngu's suggestion, I've tried: using GlobalSim; using Microsoft.Visual...
I am powershell newbie. I used a sample script and made substitute from get-item to get-content in the first line. The modified script looks like below: $file = get-content "c:\temp\test.txt" if ($file.IsReadOnly -eq $true) { $file.IsReadOnly = $false } So in essence I am trying to action items contained in test.txt stored as UNC pat...
I was reading through some articles on Caching and Memoization and how to implement it easily using delegates and generics. The syntax was pretty straightforward, and it is surprisingly easy to implement, but I just feel due to the repetitive nature it should be possible to generate code based on an Attribute, instead of having to write ...
hi all, i want to parse the XML file. i am enable to parse simple XML file. but there are little complex XML file <?xml version="1.0" encoding="utf-8"?> <Level> <p id='327'> <Item> <Id>5877</Id> <Type>0</Type> <Icon>---</Icon> <Title>Btn1Item1</Title> </Item> <Item> <Id>5925</Id> <Type>0</T...
Is there a way to decorate a method that will do some logging, then throw an exception unconditionally, as such? I have code like this: void foo(out int x) { if( condition() ) { x = bar(); return; } // notice that x is not yet set here, but compiler doesn't complain throw new Exception( "missed something." ); } If I try writi...
How can I find attribute values based on a regular expression of the attribute name in xslt? In this snippet, I am trying to match attributes like "url.title", or "page.title", etc... anything with ".title". <attribute name="withRegexp"> <value-of select='matches(@*[name()], "\.title")'/> </attribute> That doesn't work, any ideas ...
Hi! I'm working on this project that an admin user can create some User's Groups that will be working as the project roles. So, the admin will create a User Group named "SuperAdmin" and will select in a dropdownlist the users that will be part of this group. I've worked before in a solution using RoleProvider and using Controller's At...
So, I was playing around with Python while answering this question, and I discovered that this is not valid: o = object() o.attr = 'hello' due to an AttributeError: 'object' object has no attribute 'attr'. However, with any class inherited from object, it is valid: class Sub(object): pass s = Sub() s.attr = 'hello' Printing s....
I have in my cfm something like this <CFModule name="MyModule" someParam_one="#something.one#" someParam_two="#something.two#" someParam_etc="etc_etc_etc"/> And inside my module, I have an <CFSet param_name = "someParam_one"> ... evaluate("attributes." & param_name) On most of our servers, this work. But on one of our s...
In the ConsoleFx library there is a StringValidatorAttribute. This attribute has two constructors One without any parameters One with an "index" parameter Furthermore it has two Properties: Index MinLength MaxLength I want to define the StringValidatorAttribute for the first argument in row to be exactly 3 characters. So I imagi...
Is there a way to get the name of an attribute of an XML node using javascript. Lets take this as a sample XML <?xml version="1.0" encoding="UTF-8"?> <Employees> <Count name="EmployeeCount">100</Count> <employee id="9999" >Harish</employee> <Salary> <year id="2000">50 Grands</year> <year id="2001">75 Grands<...
Hi to all! I develop a custom control that have some field like below: ControlKind, Field1 , Field2 I want to change attribute of one of field per controlKind, Like: if controlKind == useField1, then Field1 show and Field2 hidde in properyGrid (or readonly or filter) can i do it ? Thanks in advance ...
During a setup creation process, I am planning to do the following (within a C# Script): Read the AssemblyVersion and AssemblyFileVersion attribute values of one DLL. Iterate all DLLs and executables in the project and apply those version to their AssemblyVersion and AssemblyFileVersion attribute values. Question now is: How to do st...
I'm new to OOP, so please bear with me if this is a simple question. If I create a class, which has attributes "a", "b", and "c", is it possible for the attributes to be an array, such that attribute a[2] has a meaning? ...
Given the following, I would not expect the compiler to allow multiple attributes that are derived from the base attribute, given that is set to AllowMultiple=false. In fact it compiles without a problem - what am I missing here? using System; [AttributeUsage(AttributeTargets.Property,AllowMultiple=false,Inherited=true)] abstract clas...
I am using ASP.NET MVC 2 Preview 2 and have written a custom HtmlHelper extension method to create a label using an expression. The TModel is from a simple class with properties and the properties may have attributes to define validation requirements. I am trying to find out if a certain attribute exists on the property the expression re...
Hi I have been through the Apple Developer guides and tutorials and I been through 2 iPhone books brushing on the subject of Core Data. I am used to handling the "value object"/"entity" side of things and then send them of to a web service or the likes. But on the iPhone I get to handle everything myself… cruel world:) The Locations, T...
I Have this Product Class i took from the examples of how to use nhibernate (but i did some modifications to it) I want to be able to map a class and all of it's references into the DB. [NHibernate.Mapping.Attributes.Class(Lazy=true)] public class Product { [NHibernate.Mapping.Attributes.Id(Name="Id",TypeTyp...