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.
I have been interested for a long time how to do so that the one instance was running only. I mean I have known in theory with the help of what it should be done, but I haven’t tried yet..Another very interesting thing is how to do as for instance I open an Excel spreadsheet and it does not open in another application, but the fact that is already open. This course enrages sometimes, but still technology is interesting.
The rustling in the Internet has brought to what is called Interprocess Communication (IPC) and there are many ways how to implement it, depending on the ultimate goal, whether you have only one instance, or as in Excel, or something else. Further study of the issue and gave birth to this article.
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.
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.
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.
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.