Skip to content

Instantly share code, notes, and snippets.

View savaged's full-sized avatar
418

David Savage savaged

418
View GitHub Profile
@savaged
savaged / BusyStateManager.cs
Created August 30, 2018 10:50
Busy State Manager - WPF helper (mini framework) for managing IsBusy state
// BusyStateManager usings
using System.Collections.Generic;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using Savaged.Info.Desktop.Messages;
// BusyMessage usings
using System;
using System.Runtime.CompilerServices;
using GalaSoft.MvvmLight.Messaging;
@savaged
savaged / LocalCachedPropertiesService.cs
Created May 24, 2019 07:59
Local Cached Properties Service (local props ini file)
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace AssureDesktop.Data
{
public class LocalCachedPropertiesService
: ILocalCachedPropertiesService
{
private const string _fileLocation = "LocalCachedProperties.ini";
@savaged
savaged / OopFizzBuzz.cs
Created July 16, 2019 14:26
Oop Fizz Buzz
namespace OopFizzBuzz
{
class Program
{
static void Main(string[] args)
{
const int lastNumber = 17;
var app = new Program();
@savaged
savaged / BoolTypeAttribute.cs
Last active August 16, 2019 16:10
Just a quick referencce on defining and using a custom bool like Attribute
using System;
using System.Collections.Generic;
using System.Linq;
namespace Savaged.Sandpit
{
class Program
{
static void Main(string[] args)
{
@savaged
savaged / PropertiesService.cs
Created November 15, 2019 15:30
Local Cached Properties Service
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Newtonsoft.Json;
namespace savaged.Services.IO
{
class PropertiesService : IPropertiesService
{
@savaged
savaged / FizzBuzz.py
Last active January 8, 2020 19:36
Python FizzBuzz (functional style)
def getVerb(i):
value = ""
r = i % 3
if r == 0:
value = "Fizz"
r = i % 5
if r == 0:
value = value + "Buzz"
if value == "":
@savaged
savaged / Patterns.Switch.Lib.cs
Last active January 31, 2020 13:39
Simple C# 8.0 pattern matching switch example
using System;
namespace Patterns.Switch.Lib
{
public class GreetingService
{
public string GetGreeting(string? name)
{
var value = name switch
{
@savaged
savaged / WrappedConsoleCommand.cs
Created March 25, 2022 13:34
C# wrapped terminal/console command
using System;
using System.Diagnostics;
using System.Text;
namespace Savaged.ConsoleWrapping
{
class Program
{
static void Main(string[] args)
{
@savaged
savaged / EmptyModelObject.cs
Created April 20, 2022 07:30
Empty Model object to avoid null reference issues
public class EmptyThingModel : BaseModel
{
private static readonly ThingModel _default = new EmptyThingModel();
static EmptyThingModel() { }
private EmptyThingModel() { }
public static ThingModel Default => _default;
@savaged
savaged / savaged.cli.ConsoleWithDI.App.cs
Last active June 15, 2022 11:11
Console App with dependency injection
using Autofac;
using savaged.cli.io;
using savaged.cli.modules;
namespace savaged.cli
{
/// <Summary>
/// Usage in Program.cs
/// App.Current.MainModule.Run();
/// </Summary>