Register file extension

For one project I needed to create an association between files and programs. It does not matter, if it’s some new extension like .myextension or you want to override the opening .mp3 for your program. It is clear that you do not want to mystify users by running unfamiliar and specific applications to open computer file in a specific way, or run the reg file. Everything should be done programmatically, as desired, or to offer to reassign him to open the files by default with your program.

Thus, the aim – to register programmatically on any extension of your program.

Continue reading

DLL Within

The idea

For a long time I have done a program that uses two party libraries. It turns out that at the exit it was at least 3 files, but I want the only one file! At that time, I’m not particularly bothered by how to do it and it remained there 3 files

Now again I pondered over this problem as much better to give a link / distribute an executive file, which will run all that is necessary, you unpack the archive, to think, where the executable file. That is not necessary here laughing, this is for programmers and other technically grammar known people showing file extensions, and a simple user names are displayed only with vague icons, come see what’s what.

Thus, we do so that could be implemented in a single file, all libraries, as well as his third parties.

Continue reading

Visual Studio Multi-Project Templates

The idea

In a previous article I’ve already talked about how to create project templates. There I talked about the nuances of creating templates in VS2008 and VS2010, how to set up data, files and so on. This is certainly all right, but always wants more.

If the studio can create multiple projects for one solution, and that means we should be able to in theory do the same. And as applications, I think we will find. You can just make a blank for the domain, infrastructure, services, and interfaces, all at once to set up the relationship and create a single click (or, I don’t remember how much it needs to create as they have to create a project).

So, let’s do a multi-project types solution.

Continue reading

ObjBin Cleaner Service

For a long time I have wanted to do a program that on a regular basis would check the folder  with the projects  and delete from there autogenic folders of  type obj and bin, extra everything, generate ReSharper and folders TestResults. For some, this may not be a problem, but if there is enough in the development of several large projects it becomes a problem, all this may take up to 2 gigs, for example, as I have. Can you imagine even imagine a situation where on one machine running a lot of people, each with its own folder with the project and after the session there is no clean up these folders. Once again, here are cleaning working stations, we found that in these locations was 60+ gigs! Thus, the usefulness of utility, which would all have daily been removed – is obvious.

For this purpose, I decided to use the Windows Service. Some people say that’s easier to write .bat file, but I do not own this magic and did not want to mess about, Windows Service seemed more attractive prospect in terms of new knowledge.

Continue reading

Visual Studio. Project Templates

Recently, I’ve started not just a bit but a lot experimenting with the code approaches, writing some test scripts and applications. The result, of course, always different, but not this will be discussed today. Gradually you begin to tire of setting standard projects. For the library project we need to delete class, created there by default, because it will be too lazy to rename. I am pleased to still redirect all output of compilations to the same folder at the root of the project from all libraries, not dawdle in the folders ..\bin\Debug \ for each component of the project, to remove *.dll. For Test projects deleting useless junk is especially actual! It would be nice to also set the attributes for the assembly and the information on it for everything.

I want if you need to create something new you will chose the project – and everything is already set! And the total output folder, and the appropriate values ​​in AssemblyInfo are prescribed, and nothing too much lying around in the project. I thought  and remembered that there is an option in the studio «Get online Templates», and if it is online it should be also offline – for my own templates. Said and done

As a result, I am very happy that I spent an hour to set up all necessary projects and now I do not digress into the process, but I am glad everything turned out fine and that we should not waste time on dumb work.

To learn how to do it in Visual Studio 2008, 2010 will be discussed further. Also it wil be discussed how to delete, and import ready-made project templates in the studio.

Visual Studio 2008

Beginning more than a banal and known to the pain everyone – open studio and create the desired design.


Continue reading

PostSharp. Overview.

Before turning directly to the theme of the story, it is necessary to say a few words about the system things.

Aspect-Oriented Programming

Aspect-oriented programming (AOP) - programming paradigm, based on the idea of separation of functionality to improve the partitioning the program into modules.

There are many classes of problems whose solution is impossible in the context of the OOP, or lead to a large rubbish code and connectivity modules that bad. For example, logging. In order to keep a log of the program, it is necessary in each service method of placing multiple lines of service call logging, as it may have to pass through the input parameters of methods. All this code would not apply to the implementation of real-world task entrusted to the method, but only an eyesore. Besides, how many extra lines of code have to write by hand!

Another example is the authentication and verification of access rights. In good, before the execution of important methods, one must each time test whether the current user rights to run the specified method. Here, too, can be a lot of hassle and code

In general, any cross-cutting code drops out of the opportunities the PLO. AOP programming, by contrast, provides all the tools to highlight “through the code in separate entities, which significantly simplifies the code for testing and for use.

Continue reading

Design pattern “Specification”


This article is mostly for beginners at programming, who know only some programming patterns or don’t know them at all.

About design patterns

Let’s take definition of design pattern from Wikipedia.

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

For instance we can imagine that we are accomplishing a task “by analogy”. Or, for example, solving the same equation, but with another concrete numbers.

Pattern “Specification”- is a pattern of supplement’s conduct. The result of the implementation will be a Boolean variable; giving you the input of the operator of conditional transfer you control the behavior of the program.

With the help of the following techniques you can:

  • Make your code more readable and concise
  • Avoid duplications of code
  • Easier to make changes to the implementation

As always, the work of the complex mechanism better shows a concrete example. Let’s start with simple things, gradually moving to the complex. I will try to avoid situations in which revealed only a simple example, but as it is applied in real life – unclear.

Continue reading

Featured Common Controls

I would like to share my little library, which make my life easier when I create an user interface. At all, there are the same standard components, but with smart tags. They adapt on general and private fields. After starting installer and successful end of its work, you can find a new toolbar in the studio.

The library determines to GAC, creates a new toolbar in Visual Studio, and adds to a dialog box «Add reference…». You can read how to do it on your own in the one of my previous articles.

You can load the installer or a source code for these components and make a light setup for personally you or add your components. Don’t be shy to give suggestions which other elements of the UX can make better, what often uses and can be useful.

Source code and Installer

Next I will describe in short components which a library includes.

Continue reading

ReSharper Recipes. File templates.

Now I’ll redeem a promise about which I’ve told in the previous article. I’ll tell you how to reduce your working hours which you spend on writing tests.

If you can create new classes with the help of alt +ins in the Solution Explorer, why don’t we create text classes with all we need at once?

It is really possible, but in a more trivial way. So, let’s start.

Again we need a draft, but now we can use it with different names and with all inclusions of «using ». So, let’s use this code for our experiment.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests {
    public class Class1 {
        public void TestMethod() {  }

Continue reading

ReSharper: Code snippets for tests.

I’ve always felt too lazy to key in full words, write different standard formulatings, it usually drives me crazy or make me bored. Some time before it hasn’t been so ruefully, but during these two years of working with ReSharper everything redoubled, for instance I don’t type «public» at all, I prefer to type «р» and press space, so ReSharper will finish writing. The only thing that I write by myself is names of methods, classes and tests. I would like to stress that only the names and not all notes. And variables are always named by ReSharper too. =) I’m a real sluggard!

I would like to share my knowledge with you how to develop such laziness and how ReSharper helps in it. Because of we hold to Test Driven Development, all code snippets will hold to texts.

All texts begin with an add of text class.

using Microsoft.VisualStudio.TestTools.UnitTesting;

public class classname { }

Everything doesn’t change except the title of text class. I physically suffer from the look how the others write it. In information about myself I’ve told that at work we practice XP and that’s why pair programming is the imprescriptible point.

After choosing the class you need to choose the text method.

public class classname {
    public void name() {

Look how much text there is! And there are only 2(two) comprehensible words! Typing everything isn’t the easy way, so we need to automatize it. With the help of the ReSharper it does quite fast and easy.

Continue reading