pattern

How to create .NET interface with static members?

In .NET 3.5, I'd like to create a singleton interface: interface ISingleton <T> { public static T Instance {get;} } Of course that doesn't work but is what I'd like. Any suggestions? EDIT: I just want it to be known that all singeltons will have a static property named Instance of the class type. It is always there. An interface w...

Closest match for Full Text Search

Hello, I am trying to implement an internal search for my website that can point users in the right direction in case the mistype a word, something like the did you mean : in google search. Does anybody have an idea how such a search can be done? How can we establish the relevance of the word or the phrase we assume the user intended t...

Handling Dialogs in WPF with MVVM

In the MVVM pattern for WPF, handling dialogs is one of the more complex operations. As your view model does not know anything about the view, dialog communication can be interesting. I can expose an ICommand that when the view invokes it, a dialog can appear. Does anyone know of a good way to handle results from dialogs? I am speakin...

Data Transfer Object Pattern??

Hi Guys I've got a problem where I need to generate a Word based reports on object “Customer”. I usually do this by passing Customer to a class which knows how to create a Word document, insert bookmarks etc. The problem with this, is that I find myself placing the logic for retrieving and formatting information about the Customer obj...

Should MVC Controller be in separate DLL?

I've created a .NET winforms MVC. The Controller and View are in the same EXE. Model is in a set of DLLs that get used by several groups. The MVC is very explicit. Model knows nothing of Controller and Controller knows nothing of View. I'm thinking to put the Controller in its own DLL so that it can be unit tested. Highly unlike so...

.NET MVC: How to create form from controller?

In .NET 3.5 winforms, I've created an MVC. I'd like to take the controller part and put it into a separate assembly, so that it has no knowledge of the view. My app uses five forms in its view. The controller takes care of initializing the forms at different times, which means the controller has a reference to the view (something I'd ...

Regex in Java, finding start and end tag

I am trying to find data within a HTML document. I don't need a full blown parser as it is just the data between one tag. But, I want to detect the 'select' tag and the data in between. return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); /// E...

Composite Pattern Iterator without recursion

Has anyone written or thought about writing an iterator for a composite (tree) structure without using recursion? If so can you share your ideas? Thks Edit: I was thinking of Java for lang. ...

webservices and attribute types

I'm currently working on a project which exposes some functions through webservices. Trouble is, some calls should return an array of "Attribute", which is a container class for a database cell. These attributes are, obviously, of different types (int, string, date, timestamp and so on). Nothing really hard, just basic types. By now, th...

How to escape extended pathname expansion patterns in quoted expressions?

In addition to the basic *, ? and [...] patterns, the Bash shell provides extended pattern matching operators like !(pattern-list) ("match all except one of the given patterns"). The extglob shell option needs to be set to use them. An example: ~$ mkdir test ; cd test ; touch file1 file2 file3 ~/test$ echo * file1 file2 file3 ~/test$ sh...

Different ways to implement 'dirty'-flag functionality

Almost every programmer did it once in his life: setting some flag if a variable's value changed. There's always lots of properties and you want to keep track if something changed in any property in a specific property or in some set of properties I'm interested in different ways to implement the "dirty-flag" functionality for the a...

C# Good way to close a form.

Say I want to open a new form.. TestForm test = new TestForm(); What is the good way to close it? More precisely, is only calling close() ok? Should I use the using() {} so dispose() is called ? And finally, suppose there is a dialog that should have only one instance of a dialog opened, is there a well "known" pattern? I've got di...

C# Multi Thread Design Example

I am relatively new to C#/.Net. I'm developing a desktop application that requires multi threading. I came up with the following pattern below as a base. I was wondering if anyone could point out how to make it better in terms of coding, being thread safe, and being efficient. Hopefully this makes some sense. public abstract class Th...

Regex replace, but only between two patterns

Ok, I have a multi-line string I'm trying to do some clean-up on. Each line may or may not be part of a big block of quoted text. Example: This line is not quoted. This part of the line is not quoted “but this is.” This one is not quoted either. “This entire line is quoted” Not quoted. “This line is quoted and so is this one and so is ...

Enum vs Lookup table vs Enum reflection vs State pattern

The software I will be building will involve "application" switching between different status a lot. Certain tasks can be done depends on the status an application is at. I was thinking about using enum as the status public class Application { public int Id {get;set;} public Status {get;set;} } public enum Status { [Description("N...

Multi-touch design and interaction pattern, do you have any link ?

Hi, I develop a collaborative business application on a multi-touch device like Microsoft Surface. However to my mind every collaborative application on a multi-touch device was made to share photos, to draw, to play, or for one person at time. So, I have no reference and I'm having a hard time to imagine how multiple users can work on ...

Regex: How to match a string that contains repeated pattern ?

Is there a regex pattern that will match a string that contains repeated pattern, e.g.: "a"|"b","c"|"d",...,"y"|"z" Do you have any idea? Thanks. ...

Match between column values returned from LIKE constraint in SQL

Hi! I am trying to match column values returned, but values are returned as a result of pattern matching: select app.employees.id, app.employees.name, app.employees.current_bp, app.designation.designation from app.employees, app.designation where app.employees.id like 'khsn?' = app.designation.desig_id like 'khsn?'; As you can see,...

Ambient objects in .NET

Hi, How do i create ambient objects in .NET that are available throughout a method chain. For e.g. the TransactionScope object. ...

How can I repeatedly match from A until B in VIM?

I need to get all text between <Annotation> and </Annotation>, where a word MATCH occurs. How can I do it in VIM? <Annotation about="MATCH UNTIL </Annotation> " timestamp="0x000463e92263dd4a" href=" 5raS5maS90ZWh0YXZha29rb2VsbWEvbGFza2FyaS8QyrqPk5L9mAI"> <La...