Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Christian Findlay MelbourneDeveloper

🏠
Working from home
View GitHub Profile
View Protobuf.cs
[HttpGet]
public IActionResult Get()
{
var person = new Person
{
FirstName = "Sam",
BillingAddress = new Address
{
StreeNumber = "100",
Street = "Somewhere",
@MelbourneDeveloper
MelbourneDeveloper / countrydata.cshtml
Last active Jun 28, 2022
Country Data Razor Page
View countrydata.cshtml
page "/countrydata"
@using BlazorApp1.Data
@using RestClient.Net;
<h1>Countries</h1>
<p>This page shows data about countries.</p>
@if (countries == null)
{
<p><em>Loading...</em></p>
}
else
View ioc_container.dart
class IocContainer {
final Map<Type, Object Function(IocContainer container)> _factories = {};
IocContainer add<T>(T Function(IocContainer container) get) {
_factories.putIfAbsent(
typeOf<T>(), () => get as Object Function(IocContainer container));
return this;
}
T get<T>() => _factories[typeOf<T>()]!(this) as T;
View BadStringFormat.cs
using System.Globalization;
namespace CodeRulesExample;
public static class Program
{
public static void Main() =>
Console.WriteLine(string.Format(new CultureInfo("en-US"), "Hello {0}{1}!", "World"));
}
@MelbourneDeveloper
MelbourneDeveloper / bloc.dart
Last active Mar 6, 2022
My Version of Bloc
View bloc.dart
import 'dart:async';
import 'package:flutter/foundation.dart';
class Bloc<T> {
late T _state;
final T initialState;
late final Future<T> Function(T state, BlocEvent event)? _eventHandler;
late final T Function(T state, BlocEvent event)? _eventHandlerSync;
final StreamController<T> streamController = StreamController<T>.broadcast();
@MelbourneDeveloper
MelbourneDeveloper / TypelessGaphQL.cs
Last active Feb 5, 2022
Typeless GraphQL Select
View TypelessGaphQL.cs
using GraphQLParser;
using GraphQLParser.AST;
using Jayse;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Immutable;
namespace TypelessGraphQL;
View CodeAnalysis.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
View MultiTargeting.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0, net45, netstandard2_0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@MelbourneDeveloper
MelbourneDeveloper / Example.cs
Last active Jul 29, 2021
Null Object Pattern Example
View Example.cs
#nullable enable
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject4
{
public interface IDependency { void DoSomething(); }
public class NullDependency : IDependency
{
@MelbourneDeveloper
MelbourneDeveloper / JsonExtensions.cs
Created Jun 24, 2021
Converts Json to a Json Object (ImmutableDictionary<string, JsonValue>)
View JsonExtensions.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
#pragma warning disable format
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
#pragma warning disable CS8604 // Possible null reference argument.