Wednesday, November 4, 2015

C# Indexer not using the propertyItem

C# will use the property item when using indexers, but if you already have a property with that name you will have problem. To solve it use the attribute on your indexer with another name [IndexerName("MyItem")]

Friday, October 30, 2015

Specflow - how to create steps in another assembly

For some reason having steps in another assembly doesn't always work. When I tried this I found out there is a bug with specflow, that if you don't put your step class in the root of the assembly, it might not bind it correctly. So, place your step class directly in the root (not in a sub-folder). Also, in the app.config of your project with your feature files you need to have this configuration

Friday, March 20, 2015

Testing internal classes with C# and MSTest

put an attribute in the assemblyinfo.cs file in the project under test, pointing to the test assembly Project under test will have
[assembly: InternalsVisibleTo("MyTest")]

Thursday, June 26, 2014

How to make Alerts fade in and fade out with Bootstrap 3.0

I wanted to make the alerts work a little nicer by using fade in and fade out. I know there are classes in the CSS to handle the fade in, but they don't work in all browsers. So I wanted to implement some Javascript to make it work

Create a div for your alerts

<div id="alerts">


We need to create unique Ids, I have used this function to do so

   function createUUID() {
        var s = [];
        var hexDigits = "0123456789abcdef";
        for (var i = 0; i < 36; i++) {
            s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
        s[8] = s[13] = s[18] = s[23] = "-";

        var uuid = s.join("");
        return uuid;

Make a function to show the alert, by adding it dynamically

    function addAlert(message) {
        var id = createUUID();
        var JQueryId = "#" + id;


        window.setTimeout(function () {

            // closing the popup
            $(JQueryId).fadeTo(300, 0.5).slideUp(2000, function () {

        }, 10000);

Notice that when adding the alert, it is hidden. The JQuery fadeIn API will create the fade effect when the alert is showing. Using setTimeout, we start fading out, and then closing the alert. You can play with the numbers to have the effect you want, but this seems to work nice and make alerts popup nice, and close on their own

Testing the Alerts

    $(document).ready(function () {


        window.setTimeout(function () {
        }, 1000);

        window.setTimeout(function () {
        }, 10000);

        window.setTimeout(function () {
        }, 20000);

        window.setTimeout(function () {
        }, 20000);


The code

You can see the code and the full effect here

Wednesday, June 18, 2014

Membership and roles as a WCF service

In case you want to have your membership and roles exposed as a service

Click here for more information

How to create a web thumbnail

I found a lot of tools that do this but I think the one I am going to really give a try is this one

And I am going to try to add a link to CNN here:

Generated by

Wednesday, June 4, 2014

How to make technical demos better

If you are showing code, a power point and then switching to a view of the application it can be challenging so here are some tips to improve your technical demo

I don’t want to see your dog

You should not show your family or dog in your background, it is better to keep your background black or with a logo of your demo or company. You should also consider that it takes longer to render images when people view your demo in a remote location.

I don't want to see e-mail popups

I don’t want to see an e-mail pop from your wife telling you to pick up milk on the way home during a demo. For the demo, consider sharing your secondary monitor and not the main monitor. This way you don’t need to close all these items on the task bar, you don’t want to show what you have open to everyone. It also solves the issues of notifications from e-mail. Normally these e-mails notifications can pop during the demo and normally they are on the main screen. Putting your demo on the secondary screen will make sure no one sees these notifications. Of course, you can also just close your e-mail program before the demo.

I can’t see that! Can you make it bigger?

Well, there is an app for that. Download the application ZoomIt and it will allow you to zoom into parts of the screen you want to explain. ZoomIt has cool features that allows you to draw arrows and boxes around items on your screen. The best part is that it’s free!

Hold on let me find that code…

Nothing is more annoying than a developer looking for the code he wants to show in the solution. The solution to this is actually simple. In Visual Studio use Bookmarks, using bookmarks you can mark the parts of the code you want to go to. Bookmarks can be enabled from the Edit Menu. You can see all your bookmarks in a bookmark view window (in the View menu).

Oh no! Not another slide

Don’t make too many slides full of text – no matter what you are showing you are likely to put your audience to sleep. Keep your slide short, put more graphics and diagrams into them. The reason is simply because the human brain works better with visuals. However, keep most of your demo interactive as much as possible. Best demos can be when you code with the audience and explain what you are doing. Which brings me to my next point...

How do I code without errors during my demo?

If you choose to be brave and code during the demo, you better make sure your code will work. The best way to know your code will work, is to code everything and test everything before the demo. If you have a working version of your code, launch it on the main screen, and share your secondary screen with the audience (running a second version of Visual Studio). You can also have notepad with code snippets on the main as a reference. Copy pasting is another technique, however, don’t use copy past too much, you may lose the audience with large snippets. Best thing is to type it as you go… this way you keep everyone watching…

The cool thing is that your audience doesn't know you have a working reference on the first screen, and they can't see your task bar (showing 2 version of Visual Studio), so to everyone it looks like you are doing it from memory and on the fly. Making you look like a true Master Jedi.

How to make sure people are not falling asleep

Try to keep the subject interesting, pop a few jokes and get your audience to participate. A few tips to get the audience involved is to simply ask them questions. Take breaks in the demo, and let the audience have a chance to ask questions and go into more details.

So there it is – have a great demo and good luck not getting that blue screen.