properties

How to read Java properties file from a JAAS LoginModule

I'd like to read a properties file in my applications WEB-INF folder or my tomcat/apache server from a JAAS loginModule. But I'm not understanding how to properly refer to the location from the LoginModule, in a host name independent manner. ...

ASP.NET Page Properties Good Idea or Bad Idea

I have tended to shy away from adding properties to my ASP.NET pages. It never seemed like a great idea to me. However, recently I have seen the practice employed in a few sample applications. Has my aversion to adding custom properties to a page been unwarranted or is this a "it depends" situation? ...

Custom Control with Data Type property Issue

I'm building a custom user control. One of the properties must allow the end user to select the numeric data type such as int, short, long, double.... I'm having a problem figuring out what to use as an internal property type, so that when the user selects the DataType option in the property box it will give them a drop down list of...

Sharepoint custom web part property does not show up in the toolbox

I have defined a boolean property as follows: [Browsable(true), Category("Display"), DefaultValue(false), WebPartStorage(Storage.Shared), FriendlyName("Obey Workflow"), Description("")] public bool ObeyWorkflow { get; set; } I'm expecting it to render as a checkbox in the webpart's properties toolbox, however it doesn't show up...

C#: Extension properties

I am pretty sure it doesn't, but... Do extention properties exist? Will they exist? Anyone heard anything? I would love it if they did... I mean, are they not just technically a get and a set method? Now for example I would love it if I could add an extention property to DateTimeFormatInfo called ShortDateLongTimeFormat which returned S...

Handling C# Properties that shouldn't be null

When setting up some reference type properties for a project I'm working on, I came accross a few properties that needed to be properly initialized to be used and should never be null. I've seen a few ways to handle this and can't really determine if there are any major drawbacks to any of the primary ways I've seen to handle this. I'd...

COM-Interface for accessing file information (title, subject, author)?

Hi, On NTFS, any file can have extended file information based on an Alternate Data Stream. Explorer displays this as a tab in the file properties dialog. I am quite sure there is a COM-Interface for reading/modifying this information, but I seem to be unable to come up with the right terms for my search. Can anyone give me a short poi...

How do I get the length of an MP3 from its URL?

If I know the URL of an MP3 file, what is the easiest/fastest way to get its length, bitrate, size, etc? How can I download just the ID3 tag part of the MP3 to get these details? ...

Property type depends on enum value

How should i implement, in C#, a class containing a property with the type of something and then that something example : public class MyObject{ public someEnum e { get; set;} public Object ObjectDependentOnE { get; set; } } I want to be able to return the right type for my object which depends on my enum. for example if e = ...

.NET WPF XAML "BindingExpression path error: ... property not found"

I was trying to bind a collection of my W3CError type objects to a WPF ListView control. It was a nice little 13 line class... Class W3CError Public Type As ErrorOrWarning Public Line As Integer Public Col As Integer Public Message As String Public MessageId As String Public Explanation As String Public So...

Why are public fields faster than properties?

I was poking around in XNA and saw that the Vector3 class in it was using public fields instead of properties. I tried a quick benchmark and found that, for a struct the difference is quite dramatic (adding two Vectors together a 100 million times took 2.0s with properties and 1.4s with fields). For a reference type, the difference doesn...

What exception to throw from a property setter?

I have a string property that has a maximum length requirement because the data is linked to a database. What exception should I throw if the caller tries to set a string exceeding this length? For example, this C# code: public string MyProperty { get { return _MyBackingField; } set { if (value.Lengt...

Find all uses of a query in an access application

I made a standalone Access 2003 app with a bunch of forms that is beginning to get unruly. I'm trying to clean it up a bit and I'd like to do things such as find all uses of a query so that I can make some global updates. I can use ctrl-f to find uses of a query in code but my question is: Is there an easy way to search the entire app...

Exposing array-like data structure using properties

Its typical to expose internal data structures as properties to your business class. But when we have to expose array-like structures (like List<Rule> rules) we might encounter a problem of wrong usage (as in Option 1). Its suggested to expose clone of such data structures as properties, so that internal structure does not get disturbe...

Private methods and properties vs public ones regarding their memory footprints in C# (and other languages)

I remember a discussion I recently had with a fellow developer about the memory footprint of private vs public properties. I stated that private ones have less of a footprint than public ones. He claimed it makes no difference. By the way, we were talking about C#. Who is right and why? Apparently there are differences in languages. ...

Acessing the backing field in an auto property

Is there any way to access the backing field for a property in order to do validation, change tracking etc.? Is something like the following possible? If not is there any plans to have it in .NET 4 / C# 4? public string Name { get; set { if (value != <Keyword>) { RaiseEvent(); } <...

Do you think generic properties would be useful in .NET?

I'm not talking about generic classes that declare properties or fields with the type of a generic parameter. I'm talking about generic properties which could be applied to both generic and non-generic classes. I'm not talking about this: public class Base<T> { public T BaseProperty { get; set; } } I'm talking about this: public...

Are there any plans for "extension properties" in a future version of C#?

I've thought of this before and it came to mind again when reading this question. Are there any plans for "extension properties" in a future version of C#? It seems to me they might be pretty stright-forward to implement with a little more "compiler magic". For example, using get* and set* prefixes on extension method names would turn...

How can one replace the extension of a file path stored in an MSBuild property?

I have the following lines in my MSBuild project file: <PropertyGroup> <TestResultsFileName Condition=" '$(TestResultsFileName)' == '' "> TestResults.trx </TestResultsFileName> <TestResultsFilePath>$(OutDir)\$(TestResultsFileName)</TestResultsFilePath> </PropertyGroup> I need to create another file, having the same...

Workaround for VB.Net - ByRef parameter of a property

I have a legacy COM-component with an interface declaring a property like this (IDL notation): interface IPasswordCallback : IUnknown { [propget] HRESULT Password( [in] VARIANT_BOOL ownerNeeded, [in, out] VARIANT_BOOL* isResultValid, [out, retval] BSTR* password ); } This interface is implemented in a calling application w...