Today I wish to tell about the build system a dynamic, modular application using Managed Extensibility Framework (MEF). Generally this is quite an old technology, which resulted from the system Add-On from the company Microsoft. MEF was a friendly shell over the monstrous system previously proposed. The result was so good that the MEF included in delivery .Net Framework 4 by default, so no need to search and download the library separately, and worry whether the library has a person.

It is also now clear that this technology can be used in the development of Enterprise, as it is in the main supply of the framework, but it’s such an argument against which project managers do not trample. Typically, project managers are very reluctant to use technologies and products which are not mentioned in press releases MS, even if the technology is widely and successfully used by the community. Although they can understand, this is the first point on which they will be kicking in the event of any overlap.

So, MEF easy to make the application modular, and adding new libraries can be carried out on the fly, without the use of sophisticated techniques. All the code is transparent and easy to understand.

MEF can be used starting with version. Net 3.5, taking the necessary libraries from CodePlex. As you may have guessed, from there you can take the source code and see how it all works.

Main features of MEF:

  • Provides a standardized way to organize workshops for the application and its appendices. In general, supplements are not tied to a specific application and implement a common interface can be used by different programs, which generally does not cancel and tight binding to the master application. Supplements may be dependent on one another and MEF alone connect them in the correct order.
  • Provides search and download of the add-ons by MEF
  • Allows you to tag metadata additions for additional opportunities to connect and filter adds.

Continue reading

NuGet creation

NuGet creation
The last time I spoke as NuGet is used, this time it is logical to tell you how to create your NuGet package and place it on a shared hosting or on your own in a local directory, or else in the gallery.

Creating your own package NuGet

For example, and I think in most cases, you’ll create a package NuGet without dependencies on other packages. So we need any project, for simplicity let it be a simple library with the N- of methods.

In order to be able to set library or libraries to include in the final NuGet package, you must add the project file with the extension “.Nuspec“, where there will be described all the properties and the internal function of our package. So far, in the studio there is no setting to create the files required extensions, so that you can create any text file, and change it’s dwells.

In general, the nuspec file looks as follows:

<?xml version="1.0" encoding="utf-8"?>
    <title>Argument Parser library</title>
    <authors>Violet Tape</authors>
    <description>Easy to use library for parsing app arguments.</description>
    <file src="bin\Release\WBR.ArgParser.dll" target="lib" />


We can say that the comments here are irrelevant. The only thing that is necessary to specify is which tags are mandatory and which are optional.

Continue reading

NuGet using

Today I would like to talk about the use of NuGet. Surely you’ve heard something about this system of management of external dependencies. Recently, the system grows and more and more developers are putting their systems in the wrapper for distribution with the help of NuGet.

NuGet – a manager to control the dependencies on external libraries. With this tool you can install, update and remove according to your project with great ease. This applies both for the desktop software and the web. In particular, when expanding the CMS Orchard, she drags the half assembly during installation of the library on their own packages. There are examples of NuGet for Silverlight.

Notes from the back seats

When studying materials NuGet, a plus appears availability of shared libraries to your projects. Conditional opponents NuGet, or principled opposition asks why you need NuGet for their shared libraries, if there can be external to SVN, and other such things for VCS? So you can refer to the stable branch sources.

Developers NuGet answer that

  • do not control whether access to the version control system,
  • source code is not displayed to other groups
  • no need to monitor and switch to other audits by hand (maybe you want to jump from branch Release, to an earlier, or you are referring to an audit in trunk)

Quite good advantages. Especially now that your favorite library does not get lost among repositories and projects.

Continue reading

Enum with a human face

A problem

Quite often we have to use enums for a limited set of values. They are very easy to use in your code, but there are problems for bringing them to the interface of the application. Not only in Russian but in English. The values ​​in enum may consist of several words logically and embarrassing them to show in the user interface. For example:

public enum MyEnum {

Naturally, it is show to the customer CompositeValue is not good. Much better to show “Composite Value”. Or, to translate it into Russian.

Continue reading

Notepad – –

This article is somewhat unusual in comparison to all previous ones, because it’s more like a conclusion and the summaryzing of the previous articles of this season. This is an example of interaction between the components of which I wrote recently: interprocess communication, command manager, the registration of extensions. Example I named so because it was chosen as an example of Notepad++, but due to the fact that this program only shows the options capability in close to real-life, we get a minus-minus.

You can name the current compilation of the backbone for further development. Now the program can open by clicking on the file with a registered extension, the file opens in new tabs, or, if you ask, then close all other tabs and the file will open in a single tab. There will always be running only one instance at one time.

I think that I should still consider how it works in reality. Focusing only on the differences that have emerged in real life. At the same time and will be seen asdescriptive material is different from a working prototype.

Continue reading

Command Manager

Today I want to tell you about the pattern Command and Command Manager. All this went smoothly. In the last article, this is so and suggests itself, but I was too lazy to twist it back, I decided to tell apart. Although at first I had doubts as to whether to tell all. Because I go to distribute the 5 ways to implement (as the complexity and development of the idea, but then one still rejected), and this functionality is even more developed and built in WPF. In the end, I think it will be useful to beginners, to be better understood how to use it in the future, in WPF, and in general.

Let’s start with the official part, that’s what Wikipedia tells us about the purpose of this template:

Command – a design pattern used in object-oriented programming, which is for an action. The command object contains the action itself and its parameters. Provides processing commands in the form of an object that allows you to save her, to pass as a parameter of the method, and return it as a result, like any other object.

From the definition we can say that with the help of commands to make the application less connected with each other. This can be useful for writing plug-ins when there are different implementations of a single action, when to run the program, with arbitrary initial actions identified in the command line, for example.

Continue reading

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

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


As the result of previous parts we have domain with core classes and services. Actually we can generate and process any amount of data with methods provided by domain services. But there are some issues:

  • How user will input data;
  • How data will reconstitute/persist.

Domain by nature and the general plan must be absolutely independent and free from technology aspects as GUI/user interaction (WPF, WinForms, Web) and the data layer implementation (MSSQL, MySQL, Oracle, etc.)


Step by step we realize that application should be multi layered. And there are minimum possible set of layers, as I see it:

  • Domain –business logic layer. In this layer described HOW to work with data.
  • Data layer. At this level implemented saving and recovering data to/from external data storage to domain objects. Extracting these actions in separate layer makes application more agile, i.e. it’s easy to deal with several different DB without changing other parts of the application.
  • Presentation layer. Here we say WHAT to do with data: define specific sequence of domain services and return calculated result to GUI. So, this layer connects Domain and Front End.
  • User Interface (Front End). This level can be console, win forms, web, even mental transmission to mind! =) Try to keep this layer as dumb as possible. No data changes, no application flow logic – only do what other says with any initiative.

Now when we know layers responsibilities, next goal is to understand how they interconnect with each other.

Continue reading