attributes

Finding sub properties of javascript object

My code ise this: var cem = { "name": "cem topkaya" }; f_PropertyBul(cem); function f_PropertyBul(obj) { for (var prop in obj) { document.writeln(obj + " prop: " + prop + " propertyIsEnumerable:" + obj.propertyIsEnumerable(prop) + "<br/>"); if (obj.propertyIsEnumerable(prop)) { f_PropertyBu...

Custom Attribute in C# : How to create an Attribute which defines several other Attributes ?

I've the following Attributes defined on my Name field: [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(MyResources))] [Display(Order = 0, Name = ResXStrings.UserName, ResourceType = typeof(MyResources))] public string Name { get; set; } I want to create a custom Attribute which l...

Custom validation attribute with multiple instances problem

I'm using tha namespace System.ComponentModel.DataAnnotations in C# 4 to implement my own validation attribute and it looks like this [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class MyCustomValidator : ValidationAttribute { private String Property1 { get; set; } private String Property2 { get; ...

Restricting Whether a .NET Type can be passed only ByVal or ByRef

If you create a class in .NET, is there any way to place a restriction on it so that if it's passed into some method (as an input parameter), then it can only be passed by reference or only passed by value? I was thinking maybe via a attribute on the class? ...

Rails: Keep changes to objects/associations in memory without saving to database.

I have a Rails model with various attributes and has_many relationships to other models. In the view I want the user to be able to enter/change values which will change the values in the loaded object and return results calculated from them whenever they make a change. However, I don't want the values to change in the database until th...

How can I add a StyleCop rule suppression without StyleCop installed on my machine?

I would like to add a StyleCop SuppressMessageAttribute to some code but I don't want to require StyleCop to be installed. Does my project need to reference the StyleCop binaries and if so, which ones? Also, is the StyleCop SuppressMessageAttribute different to the System.Diagnostics.CodeAnalysis.SuppressMessageAttribute? ...

Pythonic solution to my reduce getattr problem

I used to use reduce and getattr functions for calling attributes in a chain way like "thisattr.thatattr.blaattar" IE: reduce(getattr, 'xattr.yattr.zattr'.split('.'), myobject) Works perfectly fine, however now I have a new requirement, my strings can call for a specific number of an attribute as such: "thisattr.thatattr[2].blaattar" ...

Why custom types accept ad-hoc attributes in Python (and built-ins don't)?

Hi there! I'd like to know why one is able to create a new attribute ("new" means "not previously defined in the class body") for an instance of a custom type, but is not able to do the same for a built-in type, like object itself. A code example: >>> class SomeClass(object): ... pass ... >>> sc = SomeClass() >>> sc.name = "AAA"...

jQuery attr() not working inside jQuery Validation plugin?! Returns undefined!

So I am using attr("alt") inside the "success" block in jQuery Validation plugin. However, attr("alt") returns undefined even though the attribute ("alt") is definitely defined. Here's my code: $(this).validate({ success: function(label) { var api = $('#' + label.attr("for")).qtip("api"); api.updateContent($('#' + ...

How to change the name of a collection of a custom class upon XML serialization?

I'm serialising a List of a class and I'm not happy about the generated XML output. [Serializable()] public class Foo { [XmlAttribute] public String Property1 { get; set; } public Foo() { } } public class Foo2 { List<Foo> _list = new List<Foo>() { new Foo(){ Property1="hello"} }; // ... // code f...

How to get attributes value

I have this code: [MyAttribute(CustomAttribute="Value")] class MyClass { // some code } Main() { MyClass a = new MyClass(); } How to get value of CustomAttribute for instance a? ...

In .NET is it faster to use the Attribute suffix even though it is not required?

MSDN states that you do not need to specify the attribute suffix when using attributes in code Example: You have an attribute named HelpAttribute. You can decorate a property with [Help] (no Attribute suffix) or with [HelpAttribute]; either is allowable. But, does the code run faster when you use the full attribute name rather...

How to escape XML attribute values, and when do I need to?

I tried writing some XML that has a line like: <node attr="{foo}"/> and loading it in C#, and getting: System.Xml.XmlException: Name cannot begin with the '{' character, hexadecimal value 0x7B. Line 2, position 14. I tried escaping with &#x7b;, but that just gives: System.Xml.XmlException: Name cannot begin with the '&' character,...

Rails 3.0, want to match 'UK' == 'United Kingdom' in ActiveRecord model

hey I have a problem, I have a Country model. where the entry in the DB is: {:name => 'United Kingdom'} The data I have is UK instead of United Kingdom. in the other models where i search for it i have done: country_name = "United Kingdom" if country.name == "UK" but i have to do this all over the application and that is just bad. S...

Help accessing xml attribute in php

Hi, I'm new to php and coding in general. I'm trying to parse xml from a remote device and access specific value data. I would like to display group 9 probe 1 value for example and I cannot get it to work. Any tips? Here is the xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <Device id="S10011" hb="1935"> <Group id="1" /> ...

Do ASP.Net MVC Controller Attributes Execute Before or After the Action?

Consider the following code: [Authenticate(Order = 1)] public ActionResult SomeActionThatRequiresAuthentication() { var model = new SomeViewModel(); // Do something with an authenticated session/user... return View(model); } Does the Authenticate attribute happen before or after the code insid...

Magento: addAttributeToFilter but ignore for products that don't have this attribute?

I'm trying to show add some filters on my store, but they have a nasty side effect. Suppose I have product type A and B. Now I want to only show A where color = blue/red. $collection = Mage::getResourceModel('catalog/product_collection') ->setStoreId($this->getStoreId()) ->addCategoryFilter($this) ->addAttributeToFilter(ar...

C# Xml Serializing List<T> descendant with Xml Attribute

Morning Guys, I have a collection that descends from List and has a public property. The Xml serializer does not pick up my proeprty. The list items serialize fine. I have tried the XmlAttribute attribute to no avail. Do you guys have a solution? public partial class MainWindow : Window { public MainWindow() { Init...

[MAGENTO] Force customer to fullfill the address form again

Hi! I created a new attribute to the address form and it is working fine, my problem is with older customers. How can I make force them to have to edit their address? WHen they go to the checkout page, they choose the old address without knowing about the new attribute, and it is really important for us that they fill it properly any ...

What characters are allowed in the HTML Name attribute?

I have a PHP script that will generate <input>s dynamically, so I was wondering if I needed to filter any characters in the name attribute. I know that the name has to start with a letter, but I don't know any other rules. I figure square brackets must be allowed, since PHP uses these to create arrays from form data. How about parenthes...