Infrastructure is hard.

When you’re developing a new app, it is often daunting to decide how you’re going to structure the app.

The MVC design pattern is a well tested, and time-honored, architecture for applications of all types.

In the last few years the pattern has gained recognition through Microsoft’s ASP.NET. this is not the only technique for creating an MVC application. The MVC pattern can be implemented in any object-oriented programming language.

Today I bring you SimpleMVC. SimpleMVC is a new package for C sharp developers that provides an API they can use to create great MVC based applications. SimpleMVC uses an asynchronous programming model to allow for usage in any kind of application such as WPF, ASP.Net WinForms and even Unity or Xamarin.

MVC is not a flavor of the month. Unlike MVVM, it is capable of creating applications that are cross-platform as well as cross UI technology. Models, View definitions, and Controllers are each encapsulated so that they can be reused across different applications that need the same business logic.

SimpleMVC uses an Adapter pattern to allow models to be transported across not only platforms but data access types. Because of this you could use MS Sql Server, Oracle, or even simple mock Frameworks to provide data to your application all without changing a single line of code in the controller the model or the View.  To accomplish this I also created SimpleDI or Simple Dependency Injection.

SimpleDI allows you to create object definitions in any way you decide to define the dependency.  For example you may use the built-in JSON formatted dependency definition or you may create a hard-coded dependency definition.

All of this is about flexibility.


The combination of SimpleDI an SimpleMVC allow you to create cross-platform, cross-application, and cross-technology implementations of applications that will grow with you as you need them to grow.


So lately at work I’ve been doing a lot of scripting. My supervisor has challenged me with automating everything we do with deployment of our applications and our AWS environment.

So, I’ve been using PowerShell….alot.

Some of the things I’ve done with PS:

1) Create a script to generate a new AWS Elastic Load Balancer
2) Create a script to generate a new AWS EC2 Instance and install SQL Server 2014 on it.
3) Create a script to build our source code with msbuild and octopack and then upload the resulting nupkg to our Nexus repository.
4) Download and install Chocolatey and have it automatically install one of our apps.

These things are all extremely useful! More scripts will be generated, especially as we move to AWS Cloud 2.0!

I’ve been working very hard on WorldBankBBS lately.  I’ve added a lot of features, and a lot more are coming soon.

Right now, you can use these features:

  1. Subboards with full screen editor
  2. IRC Gateway
  3. BBS Gateway
  4. Question & Answer FAQ System
  5. Full system search engine

To connection, simply navigate to and select the terminal emulation you prefer!

I’ve spent the last few weeks laid up with knee surgery.  In that time I’ve revisited some hobby stuff including WorldBankBBS.  Testing with Synchterm normally goes well, but when testing at 2400 baud it’s not entirely accurate.

The solution is to use WinVICE (the Versatile Commodore Emulator) to actually emulate a Commodore 64 connecting to the BBS.  To make that work, you need another program called TCPSER.  This program is a GNU/Linux native app and requires Cygwin to run on Windows.  There is a Java port called TCPSER4J, and it works fine, but you get all of the problems of having Java installed on your system.

One of the things that is a big bonus of porting TCPSER4J to C# is that it allows the application to be run as a Windows Service which ensures you always have it running.

You can check out the code at and you can check out the project at where you can download the installer.


An extension method that will be making its way into the Generic Extension Methods library is one I want to share tonight.  It’s for projecting an action N times.  Why such a method doesn’t already exist baffles me!

        public static T Project<T>(this T projected, int n, Action<T> action)


            for (int i = 0; i < n; ++i) action(projected);

            return projected;


Usage could not be simpler, any object can be projected to the specified action any number of times.

        public static int Method()


            var value = 1;

            return value.Project(10, i => i*=i);



The projection in this case yields 10^10 as the answer.  Overly simplistic example, but makes the point succinctly.

I have been working on a very interesting project lately for work. It’s a set of plugins for IE and Chrome to capture visited URLs and report them to a central server so that a remote service can be paused while the user is visiting a page in a blacklist.

To accomplish this, there is a browser helper object written Visual C++. BHO component should not be written in .net code despite the examples on the web. This is because the browser liberally shuts down COM containers which can leave the CLR in an unstable state. Trust me on this one, just bite the bullet and write your BHOs in C++.

For Chrome, things are even more convoluted. You must create a plugin in JavaScript. The manifest must declare both a background page/js and an event js file. The event js has access to the DOM, so any manipulation must be done there. The event then uses internal messaging to talk to the background js. Finally, the background js uses native messaging to talk to a command line app written in C# that accepts communications via standard in. The C# app then calls a WCF service that aggregates all of the data collected by the IE and Chrome plugins.

Did I mention that the BHO hosts its own CLR to communicate with the WCF service, too?

The WCF service is hosted in a Windows Service which also contains a cache that the WCF service populates. Once a page transaction is comple, the cache attempts to send the page data to a webapi on a central server.


For years I’ve resisted ASP.Net MVC and WebAPI.  I am (slowly) coming around to the popular opinion that they are a good technologies, but only when applied to the appropriate tasks.  I’m also working with Single Page Applications using Knockout JS.  I’m having a bit more trouble moving to the dark side on that one.  My complaints and concerns about JavaScript-heavy applications are being somewhat justified by my experiences thus far.

My tasks thus far have been very entertaining.  I’ve written a database driven rules engine that compiles rules to CLR code via the Code DOM.  I’ve built pages for our SPA, a task that has taught me a lot about ASP.Net MVC.  Most recently I’ve been working on how to improve performance of the SPA by (gasp) moving code out of the JavaScript and back into the server.  Not only that, but we’re moving the AJAX calls from MVC controllers to WebAPI.  I’ll be posting another article soon about why you should avoid MVC controllers for AJAX when using JSON to pass around the data.

So I’m very much enjoying my new job.  I’m loving having a team of people to work with that can related to my daily challenges, and it’s been refreshing to work for a manager that isolates us from the office politics and allows us to do our work!


INTRODUCTION: Over a two part series I introduced how to use an MVC pattern with a Universal Windows App.  That example simply gave a list of Game of Thrones characters for display.  I’ve extended the example to also allow editing those characters in a details page.  I’ve also added a singleton to control application state and to perform navigation.

Let’s first take a look at the Singleton, which I’ve named ApplicationSingleton.  I’ve moved the instantiation of the Controller to this class as well as removed code in App.xaml.cs that used the Frame.  Instead of a navigation frame, our Singleton will assign instances of MainPage and DetailsPage to the Window Context as the user navigates the app.

EXAMPLE: App.xaml.cs Changes

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)

            if (System.Diagnostics.Debugger.IsAttached)
                this.DebugSettings.EnableFrameRateCounter = false;

            Window.Current.Content = ApplicationSingleton.Instance.MainPage;

Now that we have the App setting it’s initial page with the Singleton, we’ll take a look at the Singleton itself.

EXAMPLE: ApplicationSingleton Code

using System.Collections.Generic;
using Windows.UI.Xaml;
using SharpNinja.Controllers.People;
using SharpNinja.Models.BlogEntities;
using SharpNinja.Utilities.MvcBasics;

namespace SharpNinja.UI.Windows10Sample2.Singletons
    internal class ApplicationSingleton
        private ApplicationSingleton()
            _personsController.Initialize(new List<IView> { _listView, _detailsView });

        private readonly static ApplicationSingleton _instance = 
            new ApplicationSingleton();

        public static ApplicationSingleton Instance => _instance;

        private readonly PersonsController _personsController = 
            new PersonsController();

        private MainPage _listView = new MainPage();
        public MainPage MainPage => _listView;

        private DetailsPage _detailsView = new DetailsPage();
        public DetailsPage DetailsView => _detailsView;

        private AppState _state = AppState.List;

        public void Navigate(AppState state, params object[] values)
            switch (state)
                case AppState.List:
                    Window.Current.Content = _listView;
                    _state = AppState.List;

                case AppState.Details:
                    Window.Current.Content = _detailsView;
                    var person = values[0] as Person;
                   _state = AppState.Details;

    internal enum AppState { List, Details }

The Singleton is used to not only manage the state of the application, but to instantiate and register the pages of the application with the PersonsController (which has not changed at all to accomodate the changes in the User Interface).

The MainPage had to be updated a little to handle the SelectedItemChanged event so that users can click a character and open their details.

EXAMPLE: MainPage.xaml Changes

        <ListView Name="lstResults" Grid.Row="1" HorizontalAlignment="Stretch"

EXAMPLE: MainPage.xaml.cs Changes

        private void Selector_OnSelectionChanged(object sender, 
            SelectionChangedEventArgs e)
            if (e.AddedItems.Count == 1)
                var person = e.AddedItems[0] as Person;

                ApplicationSingleton.Instance.Navigate(AppState.Details, person);

We now have our navigation and MainPage changes.  We can now look at the XAML for our DetailsPage.

EXAMPLE: DetailsPage.xaml Code

        <AppBar Height="50" Background="Black" IsOpen="True">
            <AppBarButton Height="50" Name="btnBack" Click="ButtonBase_OnClick">
                <TextBlock Margin="5 0 5 0">Back</TextBlock>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        <Border Grid.Row="0" BorderThickness="5" CornerRadius="7" 
                Background="Blue" BorderBrush="Yellow" 
                Margin="10 5 10 7" Padding="8" Name="nameBorder">
            <TextBlock Text="{Binding Name, Mode=OneWay}"/>

        <Grid Grid.Row="1" Margin="10 5 10 7">
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            <TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5 0 5 0">First Name:</TextBlock>
            <TextBox Grid.Row="0" VerticalAlignment="Center" Grid.Column="1" Text="{Binding FirstName, Mode=TwoWay}"/>
            <TextBlock Grid.Row="1" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Left" Margin="5 0 5 0">Last Name:</TextBlock>
            <TextBox Grid.Row="1" VerticalAlignment="Center" Grid.Column="1" Text="{Binding LastName, Mode=TwoWay}"/>
            <TextBlock Grid.Row="2" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Left" Margin="5 0 5 0">Date of Birth:</TextBlock>
            <DatePicker Grid.Row="2" VerticalAlignment="Center" Grid.Column="1" Date="{Binding DateOfBirth, Mode=TwoWay}"/>
            <TextBlock Grid.Row="3" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Left" Margin="5 0 5 0">Age:</TextBlock>
            <TextBlock Grid.Row="3" VerticalAlignment="Center" Grid.Column="1" Text="{Binding Age, Mode=OneWay}"/>
        <Border Grid.Row="2" BorderThickness="5" CornerRadius="7" 
                Background="Blue" BorderBrush="Yellow" 
                Margin="10 7 10 7" Padding="8" Name="statusBorder">
            <TextBlock Name="lblStatus"/>


EXAMPLE: DetailsPage.xaml.cs Code

using System;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using SharpNinja.Controllers.People.Views;
using SharpNinja.Models.BlogEntities;
using SharpNinja.UI.Windows10Sample2.Singletons;

namespace SharpNinja.UI.Windows10Sample2
    public sealed partial class DetailsPage : Page, IPersonDetailsView
        public DetailsPage()

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)

        // From IView 
        public void SetStatus(string message, bool isError)
            lblStatus.Text = message;
            statusBorder.Background =
                new SolidColorBrush(isError ? Colors.Red : Colors.Blue);

        public Person Model { get; set; }
        public event EventHandler<string> LoadPersonModel;

        internal void InvokeLoadPersonModel(string name)
            LoadPersonModel?.Invoke(this, name);
            DataContext = Model;


The DetailsPage uses two way binding on the Model property (an instance of the Person object defined in the IPersonDetailsView interface).  This allows the UI and Model to be updated in real time.  Because the List page uses the ObservableCollection to hold all of the instances of the Person object, even the MainPage gets updated so when you go back to it, you see the changes immediately without having to refresh the search!

CONCLUSION: Using the MVC pattern along with a Singleton is a very, very powerful method of engineering any application.  Here we see it working beautifully with a Universal Windows Application, but it could just as well be WinForms or ASP.Net.  MVVM is not the end-all-be-all of XAML-based development.  Whether you are using Silverlight, WPF, Windows Store App, or Universal Windows App, you can still use the tried and true MVC, and you get a more portable framework to boot.

INTRODUCTION: Today I got a call from a recruiter looking to fix a big problem that a client is having with bad decisions being made with about code, deployment, testing… you name it.  I expressed to the executive that called me for an interview that nothing was going to get fixed without culture change, to which he said not to worry about that because he was ordering culture change and it would happen.  Well, a pack of developers can be like a pack of teenagers… They will see any change to the way they do things as an attack on their self-worth, which then leads into a ton of passive-aggressive behavior on the part of the group that will either lead to mass firings or an organizational change near the top. 

If you want culture change in a development group, it takes time, patience and a leader with a vision that the pack will buy into.  It takes someone with the background in the new techniques that the pack can hang their hat on.  It takes concrete examples of how to accomplish the new techniques.  Finally, it takes someone willing to teach the new techniques in a way that the developers take ownership in the learning and not just being lectured to.

CONCLUSION: I politely turned down the position.  I don’t want to waste their time because the pack would just see me as part of the problem of the forced changes and I don’t care to spend my time fighting a battle like that.