Thursday, December 25, 2014

C#: Using Microsoft Unity dependency injection in Unit Tests

After working with Ninject and Windsor for a while I finally faced Microsoft Unity dependency injection container. And here is the way to build up an infrastructure for Unity container to use it for example in Unit tests.

Friday, December 12, 2014

MSSQL: Synonyms, Post Deployment scripts and Database Project.

MSSQL Synonyms allow to create proxy tables in one database for another database so we can query tables from both databases and even make joins between them. Obviously it can be done via cross-database queries, however sometimes second database is on the remote server and it is useful to have synonym for it in your database.

Thursday, December 4, 2014

MSMQ reading and writing

MSMQ is a message queue implementation by Microsoft, which allows different applications to communicate with each other quite reliable. MSMQ supports sending objects and streams, does not require any additional software. However, it doesn't have embedded subscriber (or any bus management) implementation. We used MSMQ for logging, in order to reduce database load. So we needed a reliable way of reading from / writing to MSMQ. Let’s see how it can be done.

Thursday, July 31, 2014

EF Code First: Create table out of Enum

Imagine you have a number of enums in your code. They are defining static data and you want those enums to be mirrored in database as tables with appropriate data. Here is the tip how to quickly map enums to your tables and to seed them with enum values.

Wednesday, July 30, 2014

Entity Framework Code First: Custom data context initializer

While working with Entity Framework Code First at some point you will probably decide to create custom database initializer which allow you to create/recreate database based on flag in configuration file and automatically seed this database with data, stored procedures, views etc.

Saturday, July 26, 2014

How does WebActivator work?

WebActivator allows to execute some code before application starts (or when it's shutting down). Which becomes really useful when you are making your own packages and you want your package to do some actions when application starts/shuts down. And the person who will use your package does not need to do those actions manually.

Let’s look at the features of WebActivator and get inside the source code to see how it works and what does it mean when you meet in code something like:

[assembly: WebActivator.PreApplicationStartMethod(typeof(SomeClass), "SomeMethod", Order=1]
First of all lets look at the WebActivator structure.

Saturday, July 19, 2014

Tip: skype chat commands

Recently I discovered the fact that Skype has a bunch of useful chat commands which can save time clicking around UI and overall come in handy.

Those should be used in latest Skype version and can be typed as a message, no one else will see it except you.

/get uri for example will return you an url that others can use to join the group conversation.

/remotelogout will sign out all other instances except the current one. Ain't it useful to log off Skype you left open at work? :)

/showplaces will show all the other instances where this Skype name is currently signed in.

/alertson and /alertsoff will enable/disable message notifications for current chat. By the way enabling notifications can be used with filter /alertson [text] specifying text which should appear in chat to trigger notification.

Complete list of commands can be found here or simply type /help in chat and it will give you the same link.

Thursday, July 3, 2014

Tip: Using syntax highlighter

I know i should've used this amazing SyntaxHighlighter (many thanks to the developer!) from the very beginning, but for some reason i got to it only now. So here is my quick glance on this beautiful product. :)