Kiwi Ingenuity

Thoughts from another perspective

Opening Google Chrome with Dev tools using Visual Studio 2015

Click on the drop down next to the IIS Express button in the Visual Studio Tool bar

Select Browse with ....

When the Browse with dialog box appears, click the Add button

  • Program: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
  • Arguments: --auto-open-devtools-for-tabs
  • Friendly name: Chrome with Dev Tools

Press OK button

Lastly set your newly added entry as the default.


.NET Core 1.0.0 RC2 with VS2015 Tooling Preview 1

Today Microsoft announced the availability of .NET Core 1.0.0 RC2 with VS2015 Tooling Preview 1.

The documentation about the release is available as follows:

The last link above point to the installation. I choose the Visual Studio Official MSI Installer

Another announcement made this very same day, is the realise of Entity Framework Core RC2

I then followed this tutorial to create a ASP.NET Core MVC application

Everything worked as expected!

Migrating from DasBlog to version 3.3

This weekend I migrated my blog over to version 3.3.

The process

  1. Export your blog from DasBlog using the DasBlogMS tool. This tool use to be publicly available, but that does not appear to be the case anymore. Fortunately I was able to find a copy here, thank-you Shital Shah.
  2. After you have downloaded and installed log in as Admin. Now go to http://[YourDomainName]/admin/#/settings/advanced.
  3. Under tools click on the import button. Select the XML file you created earlier.

After the import
The imported blogs reside in the BlogEngine.NET\App_Data\posts folder. You may not see these files using the solution explorer in visual studio, so open up the folder in File Explorer.
I found that I had to change the Author name for all my imports to "Admin" (i.e. <author>Admin</author>)

The application emails out a newsletter and the mailing list has some fictitious names you need to remove. Open BlogEngine.NET\App_Data\newsletter.xml and remove the unwanted entries.

Don’t get too Func-y

There have been a few posts appearing this week which themed on encouraging the reader to start using the Func and Action delegates.

It started with Ian Randall (@kiwipom) suggesting to Give your code just a little Func-y love. This was followed by Ivan Towlson (@ppog_penguin) scripting Make my Func the higher-order Func, quickly followed by Func-ier and Func-ier which wanted to improve on the separation of concern.

I thought I would add my view and say to the readers – “Don’t do it!” At least not with the example given. It’s difficult to understand and convoluted!

@itsgrego posted a tweet this week bringing our attention to Why you shouldn’t comment (or Document) code. I would think the majority of us would agree with the contents of that article. I do!

So code should be easy to read, and I would encourage you to write your code like this.

        public IEnumerable GetOrders(int customerId)
            string cacheKey = string.Format("OrdersForCustomer{0}", customerId);
            IEnumerable result = _cacheService.Retrieve<IEnumerable>(cacheKey);
            if (result == null)
                result = _ordersRepository.GetForCustomer(customerId);
                _cacheService.Add(cacheKey, result);
            return result;

Yes it’s the same as Ian’s starting point and it takes up 6 lines, but isn’t it so much easier to read and you understood exactly what the coders intention is. Come back to this code some years down the track and you will understand at first glance what the coders intention is. It’s self documented and there is separation of concern.


I must state here and now that “I love delegates” and I would encourage you all to be using them consistently throughout your projects. When you see yourself writing repetitive code (or copy / pasting) then stop and ask yourself about delegates?

I’ll take the example above and explain how I would incorporate that code in a delegate. In the real world there is more to the process about retrieving and storing data than can be described in 6 lines of code. One area of concern is error handling. If you have been wrapping your Methods in try / catch blocks then you know about repetitive code and copy and pasting.

So I’m going to change my example above to what I would consider a real world example.

        public IEnumerable GetOrders(int customerId)
            return FetchMethod(delegate()
                string cacheKey = string.Format("OrdersForCustomer{0}", customerId);
                IEnumerable result = _cacheService.Retrieve<IEnumerable>(cacheKey);
                if (result == null)
                    result = _ordersRepository.GetForCustomer(customerId);
                    _cacheService.Add(cacheKey, result);
                return result;

        private TResult FetchMethod(Func fetchOperation)
                return fetchOperation();
            catch (Exception ex)
            return default(TResult);

In the example above I have wrapped my GetOrder code into a delegate. I then send that delegate to a function I have written to take care of my error handling.

From now on each time I have to make a call and need to handle any exception I will use this new function. Thank-you Func-y!

Today we celebrate 30 years in business.

It is 30 years today that I first started a small IT company in West Auckland.CCL

The Commodore Vic 20 had been out a few years and the Commodore 64 was just entering the New Zealand market.

As an amateur I had visited the few computer shops in Auckland and thought to myself that I think I know more about these computers than the so called experts. So I gave up my full time job and started down the road of self-employment.

Back in time

But I have got to go back a few years to where the story really starts. I’m living in Copenhagen, Denmark and commuting to work every day. My commute took me past a shop front that featured this home computer which was called a “Vic 20”.

The next pay day came and that afternoon I was walking out of the shop with a home computer and a tape storage drive. The manual was less than 100 pages, but it explained what basic programming was and that is how I started considering software development as my no1 hobby.

I visited the same shop some months later and they enquired on what I have done with my computer. I explained that I had written this program to store and recall the name, address and phone numbers of all my friends. Their reaction to my amazement was they would like to purchase the software off me. They wanted to resell the software to their customers.

I was quite taken back, but a deal was struck and I had sold my software application. I had not realised it at the time but I had designed a database application. I went on to improve the software and store the data on a floppy disk drive. This made version 2 even more impressive.


The retail experience

So back to west Auckland and the newly opened Computer Shop. I was retailing the Commodore Home and Business Machines.

A year later I also had the IBM Personal Computer on the shelves using an operating system called DOS. You put a floppy 5¼” disk into the disk drive and booted up the computer. There were no hard drives in those days.

Business was good, but I was not cut out for retailing. I preferred to be in the back room cutting code and writing applications. Someone would occasionally open the door to my office and throw in pizza.

After a few years I sold the shop and moved up to Whangaparaoa and started working from home. I had a small handful of well-established customers by then and I set each customer up with a dial up modem and remote control software, so that I could respond immediately to their requests when needed. I have now been working out of my home office in Whangaparaoa for nearly 26 years.


Operating Systems

The Development tools over the years have constantly changed, largely dictated by the operating systems. At the time there were many operating systems to choose between for the PC (IBM compatible), namely MS-DOS, PC DOS and DR-DOS. The later was my favourite because you could run application concurrently!

IBM OS/2 was also a favoured operating system. It was competing with MS Windows. If you had asked me at the time who would have come out the winner, I would have picked IBM, but alas that was not to be.

My first windows experience was Windows 95. I was comfortable with that decision as the previous versions of Windows did not get good feedback from the press, but this time Microsoft had got it right.


Development Tools

There are some very good development tools that should also get a mention.

The Commodore 64 that I mentioned earlier had a development tool called Superbase 64. This application really put the Computer Craft on the map, because at the time many small companies where purchasing the C64 as a home computer, but wanting to use the computer in business also. Using Superbase we could produce some pretty sophisticated software within a short time period.

Ashton-Tate dBase was a big player back then. It was called the first truly relational database system for the PC. To this day we still have customers using applications with dBase as their backend storage system.

For many years Nantucket Corporation Clipper product was our development tool of choose. We could compile our dBase code and then it executed so much faster. Computer Craft developed an awful lot of applications using the Clipper toolset.

With the maturing of the windows operating system, there came the need for the graphical user interface (GUI). This was something Clipper could not provide. As luck would have it Clipper was now owned by Computer Associates and wanting to bring their DOS product into the Windows environment, they produced a product called Visual Objects.

With Visual Objects came GUI, object-orientation, typed variables, COM, ODBC and ADO. So much to learn, but it was all good stuff.

While using all these development tools, you do at times look over your shoulder and check out what the other in your profession are using to develop software? Borland Delphi was becoming quite popular and a variety of C++ and Pascal tools were also being used in earnest. Microsoft had their Foxpro product and Visual Basic development tool. None of these however enticed me away from Visual Objects, even though there were indicators that VO was not going to sustain the constant market change.

Then one day Microsoft announced the .Net Framework and this new programming language called C#. I spent a weekend evaluating this product and came away thinking that this time Microsoft have finally got it right (again)! The C# syntax was very similar to VO and Object Orientation was called component-orientation instead and it was not otherwise a lot of difference. To put this new found model to the test, I decided to design, develop and publish the company web site. I used Notepad as the editor of choice and compiled my work from the DOS prompt. A week later we had an internet presence on the World Wide Web.


The learning curve

On reflection of the 30 years past I have to grin at the percentage of that time that has gone into learning something new. Every occupation has a learning curve. In most occupations the exponential growth in a person’s learning curve when charted against experience curves out to what could be described as a smooth curve. The more experience you have the less learning is required. EXCEPT for the IT industry!!!

In our industry experience does not diminish the learning curve. Literally every day there is a something new to learn. Take today for example – Windows Azure has announced the general availability of AMQP 1.0 How many of us know about AMQP? The answer is not many. However we cannot simply ignore this announcement. At some time today I will need to research this new technology and have some understanding to what it does? It may be knowledge that I can use at a later date. It may be knowledge that I find out I’ve been doing it wrong all this time. Whatever conclusions I draw, it been an important part of my day to learn and understand (to some level) what this technology does and how I may be able to use it in the future.

I’m pretty sure that in the past 30 years, I have spent 10 years of that time learning something new.


Moving Forward

Well if you have got this far in reading this short essay, thank-you for reading about my experiences. I love the industry I am in, and every day is a good day.

Computer Craft moving forward is dedicated to continue learning new technologies and using that knowledge in providing Business Analytical, Project Management and Software Development skills to its customer.

A WPF Text Box Autocomplete Extender using Reactive Extensions

My objective is to design an WPF auto complete text box that I can use to make calls to a web service. I was aware of the Reactive Extensions technology, but have never up to now had an opportunity to deploy an RX solution


Reactive Extensions

Reactive Extensions appealed to me because the amount of code required to set up an observe / search routine is minimal. The syntax is very powerful.  

As an introduction to RX I worked through the example published by PeteGoo called Building an Auto Complete control with Reactive Extensions (Rx). When I had completed the exercise I had a code snippet that showed me how to create a synchronous (or asynchronous) call to a web service, which catered for:

· Throttling (idle periods before searching)

· Merging multiple event streams

· Removing duplicate consecutive events

· Cancelling previous searches

All the above attributes were important features for my auto complete text box.

I highly recommend that before you proceed any further that you read and understand Pete Goo’s example.


Popup Control

What was missing from Pete Goo’s example was a Popup that would display each time text was entered into the textbox. I also wanted to have a reusable user control which would contain the repetitive code base.

The solution that appealed was the creation of Ioan Lazarciuc called Auto Complete for Textboxes in WPF. Ioan was inspired by the AutoCompleteTextBoxAutoCompleteExtender in the ASP.NET Ajax control toolkit and also because his solution requires minimum intervention of existing WPF code.

What Ioan’s solution lacked was the ability to do an asynchronous search while the operator keyed the search phrase. PeteGoo’s solution has taken care of this for us, so we have all the code snippets required to build an autocomplete textbox. All we have to do now is put it all together.

The attached solution is my suggestion how to implement an auto complete textbox in WPF that allows asynchronous search capabilities to a web service. I will not be going over what my two contributors have already scripted, so you may want to study their solutions first before proceeding.



My extender is a WPF user control that handles all the background tasks when the operator keys a search into the selected textbox.

To call my extender is very simple.

   <!--Set up a ObjectDataProvider which contains the data we 
   intend to lookup-->
   <ObjectDataProvider ObjectType="{x:Type local:MyDataProvider}"
                       x:Key="doSearch" >
                <x:Static Member="system:String.Empty" />
    <Label Content="Type in Search Phrase:" />
    <TextBox x:Name="textBox" />
    <ac:TextBoxAutoCompleteExtender x:Name="autoTxtBox"
                                    TargetControl="{Binding ElementName=textBox}"
                                    SearchDataProvider="{Binding Source={StaticResource doSearch}, 
				                                    BindsDirectlyToSource=True}" />

And that it!

Execute the application and the popup will display suggestions as you are typing characters into you TextBox.  You can use your keyboard or the mouse to select the correct phrase.

You can download my source code and example here.

Drag and drop solution for your WPF application

Last week I needed to include drag / drop capabilities on a Tree View on a WPF application.


As usual I started cutting the code required to give me the required capabilities. After some time it became obvious that Drag Drop functionality in the MVVM world was more complicated than what I first thought. All my code was residing in code behind instead of the view model?


I took some time out to search the internet to find out how others have resolved this issue. There are many solutions to found.


I did however discover one solution that I thought was very well done. Steven Kirk (back in 2009) has created a library that he calls gong-wpf-dragdrop.


His web site says:


The GongSolutions.Wpf.DragDrop library is a drag'n'drop framework for WPF. It has the following features:

  • Works with MVVM : the logic for the drag and drop can be placed in a ViewModel. No code needs to be placed in codebehind, instead attached properties are used to bind to a drag handler/drop handler in a ViewModel.
  • Works with multiple selections.
  • Can drag data within the same control to re-order, or between controls.
  • Works with TreeViews.
  • Can insert an item into a collection, or drop one item onto another.
  • Can display Adorners to give the user visual feedback of the operation in progress.
  • Has sensible defaults so that you have to write less code for common operations

I found this library very easy to use and would recommend you consider this solution if you want to add drag drop capabilities to your WPF application.

Introducing Microsoft SQL Server 2012

This weekend I read "Introducing Microsoft SQL Server 2012" which is a free download you can get here. It is also available from kindle books.


The book outlines the new features available in SQL server 2012 ranging from improvements in reporting and management, database administration and new application development capabilities.


I enjoyed the read and now have a comfortable understanding of the new features that are available.

Anchorage of Russell

Computer Craft last month published a new web site for the Anchorage of Russell, which is a holiday home in the Bay of Island, New Zealand.

The site has a ‘photo gallery’ and accommodation information for prospective holiday guests.

Web site visitors can book online and receive immediate confirmation on availability. The site can be viewed at

Reading Data from Multiple MYSQL Tables

I have been struggling today to Read data from multiple SQL tables.

I am using the MySQL Net Connector ( and I have imported the MySQL database into Visual Studio (ADO.NET Entity Data Model) and created the relations.

I now want to collect some data from the database into my custom Business Entity.  If I query a single table I have no issues.  If I query multiple tables however, the query fails.

Here is the code I have been using:

public List<Property> GetProperties()
   using (ncsEntities dataContext = this.ncsDataContext)
      // Begin Test #1
      var q1 = from p in dataContext.ra_properties.Top("3")
               where p.street_id > 0
               select p;

      List<ra_properties> list1 = q1.ToList();
      // End Test #1   list2 is populated as expected
      // The property ra_streets is populated and is not null

      // Begin Test #2
      var q2 = from p in dataContext.ra_properties.Top("3")
               where p.street_id > 0
               select new Property
                  Key2 = p.valuation_id,
                  Address = "Some Dummy Value"

       List<Property> list2 = q2.ToList();
       // End Test #2
       // list2 is populated as expected.

       // Begin Test #3
       var q3 = from p in dataContext.ra_properties.Top("3")
                where p.street_id > 0
                select new Property
                    Key2 = p.valuation_id,
                    Address = (p.ra_streets == null || p.ra_streets.address_1 == null) ? string.Empty : p.ra_streets.address_1

       List<Property> list3 = q3.ToList();
       // End Test #3
       // This Test Fails.  The exception message is
       // Object reference not set to an instance of an object.

        return list3;


I posted the issue on Stack Overflow and I still awaiting a reply that resolves this issue.

As a work around I changed the code as follows:

public List<Property> GetProperties3()
  using (ncsEntities dataContext = this.ncsDataContext)
    string query = "SELECT ra_properties_0.valuation_id AS Key2, 
                    ra_streets_0.address_1 as Address 
                    ncs.ra_properties ra_properties_0, 
                    ncs.ra_streets ra_streets_0 
                    WHERE ra_streets_0.street_id = ra_properties_0.street_id 
                    LIMIT 0,3;";
    IEnumerable<Property> result = dataContext.ExecuteStoreQuery<Property>(query);
    List<Property> list = result.ToList();
    return list;