Skip to content

Instantly share code, notes, and snippets.


Kevin B Keboo

View GitHub Profile
Keboo / ExceptionFiltersFizzBuzz.cs
Created Mar 24, 2015
An example of C# exception filter.
View ExceptionFiltersFizzBuzz.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using static System.Diagnostics.Debug;
namespace Example
public class ExceptionFiltersFizzBuzz
Keboo / SpekkCheck.csx
Last active Dec 4, 2015
Serialize Spell Check
View SpekkCheck.csx
#r "C:\Dev\microsoft\packages\Newtonsoft.Json.7.0.1\lib\portable-net45+wp80+win8+wpa81+dnxcore50\Newtonsoft.Json.dll"
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class Spell
Keboo / MultiBinding.cs
Last active Sep 17, 2020
A simple MultiBinding class for Xamarin.Forms. This "binding" only works when directly applied to an element.
View MultiBinding.cs
WARNING: This MultiBinding implementation only works when it is directly applied to its target property.
It will fail if used inside of a setter (such is the case when used within a trigger or style).
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
Keboo / DrawerHost.xaml
Created May 17, 2017
An example left drawer that takes up space rather than overlaying the content using MDIX
View DrawerHost.xaml
<ControlTemplate TargetType="{x:Type local:MyDrawerHost}">
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<VisualStateGroup x:Name="LeftDrawer">
<VisualTransition From="LeftDrawerClosed" To="LeftDrawerOpen">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="PART_LeftDrawer">
<EasingThicknessKeyFrame Value="0" KeyTime="0:0:0.4">
Keboo / CompositeCommand.cs
Created Aug 3, 2017
Composite Commands in WPF
View CompositeCommand.cs
public class CompositeCommand : ICommand
public event EventHandler CanExecuteChanged;
private readonly IList<ICommand> _Commands;
public CompositeCommand(IList<ICommand> commands)
if (commands == null) throw new ArgumentNullException(nameof(commands));
_Commands = new List<ICommand>(commands);
Keboo / MainWindow.xaml
Last active Aug 24, 2017
MDIX DialogHost example
View MainWindow.xaml
<Window x:Class="Example.MainWindow"
Background="{DynamicResource MaterialDesignPaper}"
Style="{StaticResource MaterialDesignWindow}"
Keboo / Test.cs
Created Jan 26, 2018
Optional FizzBuzz
View Test.cs
public static void Main()
var obj = new Printer();
IFizz fizz = obj;
IBuzz buzz = obj;
IFizzBuzz fizzBuzz = obj;
for (int i = 0; i < 100; i++)
if (i % 15 == 0)
Keboo / ExampleService.cs
Last active Apr 18, 2018
A simple result implementation using the null object pattern.
View ExampleService.cs
public class Service
public Result<Person> FindPerson(string query)
Person person = ...;
return person ?? Result.NotFound<Person>(); //Not strictly neccisary; the implicit operator will do a null check.
catch (Exception e)
Keboo / Program.cs
Created May 18, 2018
Replace explicit interface implementation.
View Program.cs
class Program
static void Main(string[] args)
IFoo @base = new Base();
IFoo derived = new Derived();
Console.WriteLine(@base.Bar()); //=> Base
Keboo / Output.txt
Last active Oct 19, 2018
Data driven unit test
View Output.txt
Build started, please wait...
Build completed.
Test run for C:\Dev\unitTest\bin\Debug\netcoreapp2.1\unitTest.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.8.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.