attributes

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 'FooTestNameSpace.Foo'. Please make sure that the ...

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")] public DateTime BirthDay { get; set; } Is there a way that...

Ruby on Rails: Nested Attributes, belongs_to relation

Hello guys, I hope you can help me. I have a User entity that has a Current Location field (city and country). To old 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 the lo...

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 about keeping the coupling of components clean...

C# Attributes - Arrays or Duplicates?

Hello. I am creating a network chat client in C# as a side project. In addition to simple text messages, I also have slash-prefixed commands that can be entered into the input TextBox. I used a modular approach by creating an enum that contains all the various commands, and then decorating those commands with attributes. The attributes...

Hiding inherited named parameters on attributes C# (3.5)

Hi all, I am using PostSharp to add some compile time logic to my attributes - in once case [IndexedCategory ("CatName", CatIndex)]. The trouble comes comes in because IndexedCategory derives from CompoundAspect - which has a reasonable number of named params. Is there any way which I can prevent these from being accessed / shown by i...

How to apply a different attribute to an interface's member than that of the same member in a parent interface

Imagine an interface heirarchy like this: public interface IAnimal { string Color { get; } } public interface ICat : IAnimal { } In this case, ICat 'inherits' IAnimal's Color property. Is it possible to add an attribute to the ICat's Color property, without adding it to the IAnimal? The following is an example of what I am try...

ASP.net MVC Attribute not executed in overridden controller method

I have a custom attribute which is executing correctly when used in a method in my controller. My Controller "A" is inheriting from Controller "B" and Controller "A" is overriding one of the method of Controller "B". I have my custom attribute applied to that method but it's not executing at all. I tried putting in the base method as we...

How to set default datetime values in an XSD element

I am currently stuck at this point where I need to set an xsd element's default attribute to have a valid current date as default. I looked around (googled) but did not find anything convincing. I need to do this in declaratively. <xs:element name="UpdatedDate" type="xs: dateTime" msdata:Caption="Updat...

Embedding mov in HTML5. Validation problem!

I'm trying to embed a .mov video in a web page whose DOCTYPE is HTML5, the code is: <script type="text/javascript"> QT_WritePoster_XHTML('Click to Play', '...', '...', '400', '300', '', 'controller', 'true', 'autoplay', 'true', 'bgcolor', 'black', 'scale', 'aspect'); </script> <noscript> <object width=...

How do I give a method as an attribute argument?

I want to apply an attribute which accepts a delegate as an argument, but I can't find the syntax to do it. For example, to pass a class, you have to use typeof: [SomeAttribute(typeof(SomeClass))] What is the syntax for a delegate (I am trying to pass a static method)? [SomeAttribute(??? SomeStaticMethod ???] ...

Magento, add Clothing size attribute without Configurable Product

I want a simple way to let my user pick there clothing size before buy but Configurable Product seems like to much overkill. you have to make a product of every size and then you have to make a configurable product. the shop is for my dad and if i have to explain him how he has to do this it would be weeks for him to know this, (it took...

What is causing this Python exception?

I have a C++ app that uses Python to load some scripts. It calls some functions in the scripts, and everything works fine until the app exits and calls Py_Finalize. Then it displays the following: (GetName is a function in one of the scripts) Exception AttributeError: "'module' object has no attribute 'GetName'" in 'garbage collection' ...

How can I pass a method acquired by reflection in C# to a method that accepts the method as a delegate?

Hi, I realize the title needs to be read more than once for understanding ... :) I implemented a custom attribute that i apply to methods in my classes. all methods i apply the attribute to have the same signature and thus i defined a delegate for them: public delegate void TestMethod(); I have a struct that accepts that delegate as ...

Find XElement by Attribute value

Hi all, I have a collection of IEnumerables and each one has a different attribute values that corresponds to a different property on my business object. Here is a sample of the XML that I am querying against: <SimpleData name="zip">60004</SimpleData> <SimpleData name="name">ARLINGTON HEIGHTS</SimpleData> <SimpleData name="state"...

Why is the winforms designer ignoring attributes on overriden properties ?

I've got a user control defined like this : public partial class FooControl : UserControl { private System.Windows.Forms.GroupBox groupBox1; ... I wanted to make groupBox1.Text accessible directly from the designer so I went for the obvious solution and created the following property in my FooControl : [Catego...

In VB, How do you force an inherited class to use an attribute on the class?

I'm trying to force an inherited class to use a custom attribute. I'm creating a class library where the user who wants to create an item will do so, but be forced to add an attribute (or visual studio will automatically add the default attribute) to their inherited class. Here is what I'm hoping to achieve: BaseClass.vb: <CustomA...

Attribute for accessing custom properties in Forms Designer

I have a control that has a list of Rods. The Rods have a few public properties: public class Rod { float Angle { get; set; } Color MainColour { get; set; } int Length { get; set; } int Width { get; set; } //other private code here you need not be concerned with ;) } In the control that hosts t...

Does the OnActionExecuted Method of an attribute always execute?

Hi everyone, I've searched high and low and I can't seem to find a straight answer. If I have a custom attribute/filter will the OnActionExecuted sub always be called? Even if there is an exception thrown? Thanks ...

Accessing @attribute from SimpleXML

Hi, I am having a problem accessing the @attribute section of my SimpleXML object. When I var_dump the entire object, I get the correct output, and when I var_dump the rest of the object (the nested tags), I get the correct output, but when I follow the docs and var_dump $xml->OFFICE->{'@attributes'}, I get an empty object, despite the...