attributes

Is ">" (U+003E GREATER-THAN SIGN) allowed inside an html-element attribute value?

In other words may one use /<tag[^>]*>.*?<\/tag>/ regex to match the tag html element which does not contain nested tag elements? For example (lt.html): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; <html> <head> <title>greater than sign in attribute value</title> </head> <body>...

Find a private field with Reflection?

Given this class class Foo { // Want to find _bar with reflection [SomeAttribute] private string _bar; public string BigBar { get { return this._bar; } } } I want to find the private item _bar that I will mark with a attribute. Is that possible? I have done this with properties where I have looked ...

DirectoryInfo.GetDirectories() and attributes

I am using DirectoryInfo.GetDirectories() recursively to find the all the sub-directories under a given path. How ever I want to exclude the System folders and there is no clear way for that. In FindFirstFile/FindNextFile things were clearer with the attributes. Thanks in advanced. ...

Serializing DateTime to time without milliseconds and gmt

I have created a C# class file by using a XSD-file as an input. One of my properties look like this: private System.DateTime timeField; [System.Xml.Serialization.XmlElementAttribute(DataType="time")] public System.DateTime Time { get { return this.timeField; } set { this.timeField = value; } } ...

InternalsVisibleTo attribute isn't working

I am trying to use the InternalsVisibleTo assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says: 'MyClassName' is inaccessible due to its protection level Both assemblies are signed and I have the correct key listed in the ...

What is the difference between "lang" and "type" attributes in a script tag?

For <script> HTML tags, what is the technical difference between "lang=Javascript" and "type=text/javascript"? I usually use both, because I've always assumed that older browsers need one or the other. ...

Can you force the serialization of an enum value into an integer?

Possible Duplicate: How do I serialize an enum value as an int? Hi, all! I'm wondering if there's a way to force the serialization of an enum value into its integer value, instead of its string representation. To put you into context: We're using, in a web application that heavily relies on web services, a single baseclass ...

What is the easiest, most concise way to make selected attributes in an instance be readonly?

In Python, I want to make selected instance attributes of a class be readonly to code outside of the class. I want there to be no way outside code can alter the attribute, except indirectly by invoking methods on the instance. I want the syntax to be concise. What is the best way? (I give my current best answer below...) ...

Can attributes be added dynamically in C#?

Is it possible to add attributes at runtime or to change the value of an attribute at runtime? ...

How do you apply a .net attribute to a return type

How do I apply the MarshalAsAttribute to the return type of the code below? public ISomething Foo() { return new MyFoo(); } ...

Is there a standard framework for .NET parameter validation that uses attributes?

Is there a standard framework (maybe part of Enterprise Library... or .NET itself) that allows you to do common parameter validation in method attributes? ...

Most Useful Attributes in C#

I know that attributes are extremely useful. There are some predefined ones such as [Browsable(false)] which allows you to hide properties in the properties tab. Here is a good question explaining attributes: http://stackoverflow.com/questions/20346/c-what-are-attributes What are the predefined attributes (and their namesapce) you actua...

Custom Compiler Warnings

When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods or properties that w...

Managed C++ Assembly Attributes

Is there a way to add assembly attributes to a Managed C++ assembly? IE, specifically in C# in the AssemblyInfo.cs file, you'd typically have something like this: [assembly: AssemblyTitle("Some Assembly")] I have a private assembly attribute that I want to add (not one of the version attributes that could be added through a resource f...

Html.TextBox conditional attribute with ASP.NET MVC Preview 5

I have a strongly-typed MVC View Control which is responsible for the UI where users can create and edit Client items. I'd like them to be able to define the ClientId on creation, but not edit, and this to be reflected in the UI. To this end, I have the following line: <%= Html.TextBox("Client.ClientId", ViewData.Model.ClientId, new {...

.NET Attributes List

Hi, Is there a list somewhere on common Attributes which are used in objects like Serializable? Thanks Edit ~ The reason I asked is that I came across an StoredProcedure attribute in ntiers ORMS. ...

Ruby on Rails - Can I modify the value of an attribute before it is called?

Let's say I have this model named Product with a field named brand. Suppose the values of brand are stored in the format *this_is_a_brand*. Can I define a method in the model (or anywhere else) that allows me to modify the value of brand before it is called. For example, if I call @product.brand, I want to get This is a Brand, instead of...

C# - How to change HTML elements attributes

Hi, My master page contains a list as shown here. What I'd like to do though, is add the "class=active" attribute to the list li thats currently active but I have no idea how to do this. I know that the code goes in the aspx page's page_load event, but no idea how to access the li I need to add the attribute. Please enlighten me. Many t...

How to read assembly attributes

In my program, how can I read the properties set in AssemblyInfo.cs: [assembly: AssemblyTitle("My Product")] [assembly: AssemblyDescription("...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Radeldudel inc.")] [assembly: AssemblyProduct("My Product")] [assembly: AssemblyCopyright("Copyright @ me 2008")] [assembly:...

How can I create a custom Property for my assembly?

How can I create a custom property for my .Net assembly which would then be visible under the Details tab in Windows explorer? Something to sit parallel with "File Description", "Type", "Product Version"... etc Update: To quote my comment to Lars ... "Whilst I would have liked to do this from within Visual studio, that is certainly not...