Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Christian Findlay MelbourneDeveloper

🏠
Working from home
View GitHub Profile
@MelbourneDeveloper
MelbourneDeveloper / DecoupleClassFromInterfaces.cs
Last active Oct 30, 2020
This samples demonstrates how to decouple a class from any dependent types. This is a step up from injecting interfaces. This class approach means that the business service can be moved to an assembly that does not depend on any interfaces (types) for loading or saving..
View DecoupleClassFromInterfaces.cs
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
namespace ConsoleApp2
{
class Program
{
static void Main()
{
View Employee.cs
using System;
namespace FluentInterfaceDesignPattern
{
class Program
{
static void Main(string[] args)
{
var obj = EmployeeExtensions.CreateEmployee(default, default, default, default);
obj = obj.NameOfTheEmployee("Anurag Mohanty")
@MelbourneDeveloper
MelbourneDeveloper / Hotobservable.cs
Last active Oct 25, 2020
Hot observable implementation which is modification of Enigmativity's sample
View Hotobservable.cs
/*
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
@MelbourneDeveloper
MelbourneDeveloper / HotObservable.cs
Last active Oct 25, 2020
Use a hot observable to share
View HotObservable.cs
/*
Output
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
@MelbourneDeveloper
MelbourneDeveloper / PubSub4.cs
Last active Oct 24, 2020
Implement pub/sub with an IObservable
View PubSub4.cs
/*
Output
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
@MelbourneDeveloper
MelbourneDeveloper / PubSub3.cs
Created Oct 24, 2020
This version creates two threads and loops. It's no good.
View PubSub3.cs
/*
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
@MelbourneDeveloper
MelbourneDeveloper / PubSub2.cs
Last active Oct 24, 2020
An example of simple messaging with observable
View PubSub2.cs
/*
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
Name: Two Message: Hi
Name: One Message: Hi
@MelbourneDeveloper
MelbourneDeveloper / PubSub.cs
Last active Oct 24, 2020
An example of simple messaging with observables
View PubSub.cs
/*
One: Hi
Two: Hi
One: Hi
Two: Hi
One: Hi
Two: Hi
One: Hi
Two: Hi
One: Hi
@MelbourneDeveloper
MelbourneDeveloper / Program.cs
Last active Oct 24, 2020
Observable.Create Example
View Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Example
{
internal class Program
@MelbourneDeveloper
MelbourneDeveloper / ShapeDS.cs
Created Oct 17, 2020
C# Use Discriminated Union
View ShapeDS.cs
static void Main(string[] args)
{
FSharpLibrary.Shape shape = FSharpLibrary.Shape.NewCircle(1);
Console.WriteLine($"Is this a rectangle: {shape.IsRectangle}");
}
You can’t perform that action at this time.