1
голосов
2ответов
2119 просмотров

Dependency Injection and .NET Attributes

I have a couple of method attributes which do some logging. Our logging code sits behind an interface (ILog) and I'd like it if the attributes were only dependent upon that interface as opposed to an implementation. This isn't really about testability or dependency inversion so much as it is abou...

9
голосов
4ответов
10773 просмотров

Ruby on Rails: Nested Attributes, belongs_to relation

I have a User entity that has a Current Location field (city and country). To hold this info I created an entity called Location which has_many Users. I'm not entirely sure if I should put in the User model "has_one" or "belongs_to", but for what I read if I wanted it to have the foreign key of ...

1
голосов
2ответов
264 просмотров

How to make a Attribute aware of the Name of the Proprty it is on?

I want to implement a simple attribute that is used to map Database Columns to Properties. So what i have so far is something that attached like so: [DataField("ID")] public int ID { get; set; } [DataField("Name")] public String Name { get; set; } [DataField("BirD8")] ...

4
голосов
2ответов
369 просмотров

Complex class declaration confusing forms designer?

I have a class declared as: public class Foo<T> : Panel where T : Control, IFooNode , new() { ... } I added it by hand to test it, but I will eventually need something that can be displayed in the Forms designer. The Forms designer doesn't like this, it says: Could not find type '...

1
голосов
1ответов
1513 просмотров

NHIBERNATE: How to map a collection into the DB using Mapping.Attributes

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 { [NHiberna...

1
голосов
1ответов
1442 просмотров

Setting an attribute on an entity and retrieving it with "one-to-many" relations

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 ...

20
голосов
2ответов
15853 просмотров

Get Custom Attributes from Lambda Property Expression

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 attribut...

5
голосов
1ответов
1324 просмотров

Honouring of AttributeUsage on derived attribute types

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,AllowMul...

0
голосов
2ответов
3508 просмотров

Can the attributes of a class be an array?

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?

8
голосов
3ответов
10344 просмотров

Programmatically change the AssemblyVersion and AssemblyFileVersion attributes

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 attribu...

1
голосов
1ответов
1014 просмотров

Change Property Attribute Like ReadOnly at Design-Time (PropertyGrid)

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

0
голосов
4ответов
119 просмотров

attributes.someParam cannot be evaluated in coldfusion

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...

86
голосов
7ответов
14032 просмотров

Can't set attributes on instance of "object" class

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...

2
голосов
2ответов
1550 просмотров

Asp.net MVC - How can I get user roles without knowing these roles?

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 R...

3
голосов
3ответов
412 просмотров

Difference between DebuggerDisplayAttribute and DebuggerDisplay

[DebuggerDisplayAttribute("{_name}")] vs [DebuggerDisplay("{_name}")] Is there a difference? Is one an alias of the other? Does VS automatically check for a class named fooAttribute when using an attribute named foo?

0
голосов
1ответов
970 просмотров

Match XML Attribute by Attribute Name? XSLT

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()], "\.titl...

10
голосов
7ответов
2675 просмотров

How to mark a method will throw unconditionally?

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(...

10
голосов
4ответов
2247 просмотров

How to inject/generate plumbing code into methods decorated with an Attribute?

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...

0
голосов
2ответов
297 просмотров

VisualStudio.TestTools.WebTesting.TestDescriptionAttribute Syntax

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...

17
голосов
6ответов
14912 просмотров

Callback for changed ActiveRecord attributes?

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 |att...

3
голосов
2ответов
114 просмотров

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 } }

1
голосов
2ответов
1218 просмотров

MVC Style Filters on ASMX Web Services, is it possible?

Is it possible to create MVC style filter attributes (like Authorize or HandleError) that work on ASMX Web Services? Specifically, I perform custom authentication on a number of my web methods and would like to wrap the code into an Attribute that throws an exception, if the authentication check...

0
голосов
1ответов
696 просмотров

jquery accessing/changing value attribute of an element

how to deal with value attribute of any element (hidden input in my case) i have tried with two styles alert($("#projectManager").attr("value")); and alert($("#projectManager").val()); but it returns 'undefined'. any help?

1
голосов
2ответов
632 просмотров

Reusing xml for-each blocks in XSLT?

I have an attribute whose value is the XPath to the current node, like so: <xsl:attribute name="path"> <xsl:for-each select="ancestor-or-self::*"> <xsl:if test="name() != 'root'"> <xsl:value-of select="name()"> <xsl:if test="not(position()=last(...

4
голосов
7ответов
7645 просмотров

Is it possible to modify the attribute of a property at runtime?

Is it possible to modify the attribute of a property at runtime? let's say I have some class: public class TheClass { [TheAttribute] public int TheProperty { get; set; } } Is there a way to do this? if (someCondition) { // disable attribute. Is this possible and how can this be d...

3
голосов
3ответов
356 просмотров

Resources for Reflection and Attributes usage

Are there any good resources out there that explain attributes and reflection and their many uses in depth? I am especially interested in best practices, i.e. when it would be useful or appropriate to use attributes and reflection to solve specific computing problems.

8
голосов
3ответов
70299 просмотров

how to get rel value of clicked element

hi im trying to get the rel value of a button that is click: function forwardStep() { $("#forwardStep").bind("click", function(){ var page = $(this).attr('rel'); thats pretty much the basis but is return "undifined". Do you know why? Regards Phil Jackson

0
голосов
2ответов
113 просмотров

Is there any way to have a static regular expression class and use with attributes?

I would like to add a regular expression to a nattribute from a static class. [RegularExpression(MyRegex.DecimalRegEx)] from a class: public static class MyRegex { public static string Decimal_Between_1_And_100 { get { return...

8
голосов
2ответов
7717 просмотров

Attributes on Many-to-Many relationships (Hibernate)

I have entity classes A and C. They are mapping the tables tblA and tblC and have a many-to-many relationship between them, with tblB to map between them. tblB contains A_ID, C_ID and SetDate, the last one being the date it was set, thus an attribute to the relationship. My question is, how do I ...

1
голосов
4ответов
1458 просмотров

Can you access a long description for a specific enum value

I usually access enum description for a corresponding value like: Enum.GetName(typeof(MyEnum), myid); I need to have an enum that could use any chars like "hello world %^$£%&" I've seen people attaching an attribute and adding extensions like here: http://weblogs.asp.net/stefansedich/arch...