attributes

C# Attributes mandatory property.

Hello, I've created attribute like [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [Serializable] public class TestPropertyAttribute : System.Attribute { public string Name { get { return _name; } set { _name = value; } }string _name; } and I should ma...

override save and load of an attribute in magento

Hi How can I override the way magento saves and load a specific attribute? I want to create an attribute that implements a many-to-many relation to products so I have a custom table with entity_id and attr_id. I'm using a multiselect attribute but magento saves the values as csv in a text field. I want to override this functionality and...

Magento: how to filter the result of Mage::getResourceModel('eav/entity_attribute_collection') by Category

I've used the follow code to get the whole list of manufacturer. $currentCategory = Mage::registry('current_category'); $product = Mage::getModel('catalog/product'); $attributes = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($product->getResource()->getTypeId())->addFieldToFilter('at...

Find an attribute that contains a ceratin string and modifying its Value in c# using LINQ

Hello, I'm trying to find the first attribute in an xml file that contains the string "name" (case insensitve) in it and then change its value. Here is an example of my xmls //XML 1 <CtApproachTypes DataclassId="1992A9CE-B048-4676-BFD4-FD81F1A65401" EntityId="1992A9CE-B048-4676-BFD4-FD81F1A65401" Name="PAR" Remark="No Rema...

python: defining registry in base class

I'm implementing enumeration using a base class that defines a variety of methods. The actual enumerations are subclasses of that, with no additional methods or attributes. (Each subclass is populated with its own values using the constructor defined in the base class). I use a registry (a class attribute that stores all the instances o...

What are the advantages of attribute based programming ?

Hi, I am working with WCF RIA services and have come across a sample using attributes: [StringLength(10, ErrorMessage="Too long")] public string FirstName { get; set; } ... While attributes aren't restricted to WCF RIA, it reminded me of a question: why is declarative or attribute based programming perferable to coding a validation r...

Why are attributes lazily instantiated?

I've found that attributes in C# seem to be lazily instantiated. [A(123)] class A : Attribute { public A(int b) { GetType().GetCustomAttributes(true); } } In this example, creating a new A instance causes a StackOverflowException, but if I remove the call to GetCustomAttributes(), then execution carries on normally...

Use reflection to get attribute of a property via method called from the setter

Note: This is a follow-up to an answer on a previous question. I'm decorating a property's setter with an Attribute called TestMaxStringLength that's used in method called from the setter for validation. The property currently looks like this: public string CompanyName { get { return this._CompanyName; } [Tes...

XSLT and XPATH: Not able to Read Certain Attributes

<field type="math" size="12" unitText="%" unitPos="back"/> I am able to select "type" and "12" from their respective fields but I cannot do the same for unitText and unitPos. Any ideas why? Below is what I'm using to print type and size. <xsl:value-of select="@size"/> I am entering the "field" tag with this line <xsl:template mat...

How do you get the attributes of a Child Array using TFHpple?

I'm using TFHpple (which uses XPath) to parse an HTML document. I can get the content of various nodes, etc. But the code I found on GitHub seems incomplete. It has a method to get the attributes of a node but the child array. So I wrote one and failed. The two "attributes" methods below work fine. Basically, I'd like to get the child ar...

Nesting appSettings with the file attribute

I'm trying to pull off an inheritance chain of appSetting sections (VS2010 C#) Given this, Base.config <appSettings> <add key="basekey" value="basevalue"/> </appSettings> Derived.config <appSettings file="Base.config"> <add key="derivedkey" value="derivedvalue" /> </appSettings> App.config <configuration> <appSetting...

Class extending - best practice/best solution

First thing to note - I KNOW DELEGATION AND DECORATOR PATTERNS! Second - I am using C# .NET 4.0, so if you come up with a solution that is specific for it, that's fine. But if solution will work for any OOP language and platform, that would be great. And here the question goes... I have a partial class (lets name it Class1), which I c...

What is the best way to do automatic attribute assignment in Python, and is it a good idea?

Instead of writing code like this every time I define a class: class Foo(object): def __init__(self, a, b, c, d, e, f, g): self.a = a self.b = b self.c = c self.d = d self.e = e self.f = f self.g = g I could use this recipe for automatic attribute assignment. class Foo(obj...

remove attribute display:none; so the item will be visible

The element is : span { position:absolute; float:left; height:80px; width:150px; top:210px; left:320px; background-color:yellow; display:none; //No display border: 3px solid #111; } i use this code to remove the display so it can be visible $(...

phptal: how do I repeatedly add attributes?

Hello there, I got a phptal template question, I have an associative array which contains HTML attribute information, eg attrs['href'] = 'www.google.com'; attrs['id'] = 'the_link'; ... Is there a way to use the "repeat" to loop through my array and generate the attributes dynamically? (I know how to do it statically) so I can have ...

Is it possible to initialize a property of an attribute class by where it's marked?

I have an attribute to mark enum fields named BusinessDescription. public enum FailReason { [BusinessDescription(Description="the client cancelled the order")] Client = 0, [BusinessDescription(Description="vender cancelled", DBValue = 1)] Vender = 1, [BusinessDescription(Description="other")] Other = 2 } You see, the...

On changing an image source to the source of another image with jquery.

Should the following code not work? $('.elastica').click(function(){ document.getElementById('bigimage').attr('src')= $(this).attr('src'); }); It doesn't change a thing on the site. I've also tried this outputting the image location trough the the other image's id, but it comes up empty (literally ""). When I output the other imag...

Accessing XML attributes with namespaces

How one can access attributes with namespaces? My XML data are in a form val d = <z:Attachment rdf:about="#item_1"></z:Attachment> but the following does not match the attribute (d \\ "Attachment" \ "@about").toString If I remove the namespace component from the attribute's name then it works. val d = <z:Attachment about="#item_1"...

Jquery: Select full href with a 'contains' method.

Hi to all, Is it possible using jQuery to select one full link which href contains another variable? My code is: var element1 = $(".not-viewed").parents('li').attr("id"); var element2 = $(".videoTitle").attr("href"); Where i need to select a full link that contains 'element1',because there several videos in the page.In my code sele...

Regex Parsing HTML

Possible Duplicate: RegEx match open tags except XHTML self-contained tags I would like to ensure that HTML attributes have quotes around them as is required by xhtml. For example: <BODY link=#0000ff vLink=#800080> should be <BODY link="#0000ff" vLink="#800080"> I am looking for a Regex pattern that would handle this. ...