Skip to content

Instantly share code, notes, and snippets.

View domingoladron's full-sized avatar
💭
alive

Chris Laine domingoladron

💭
alive
View GitHub Profile
@domingoladron
domingoladron / Blazor-WASM-VS-Code-launchsettings..json
Created January 15, 2022 05:13
A launchsettings.json for debugging Blazor WebAssembly in VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/MyBlazorWebAssemblyApp",
"url": "http://localhost:5000",
"browser": "edge"
@domingoladron
domingoladron / powersprite-animator-attach-subanimation.cs
Last active January 4, 2022 03:52
An example powersprite animator event, node and prefab instantiation
void AnimSpawn( Object prefabToSpawn )
{
/// Spawn an effect on the position from node 1 in the animation
/// prefabToSpawn is the prefab identified in our Event trigger
/// SpriteAnimNodes is a C# class included in Powersprite
/// which you add to your creature / character animation
Instantiate(
prefabToSpawn,
GetComponent<SpriteAnimNodes>().GetPosition(1),
Quaternion.identity
@domingoladron
domingoladron / DDD-ApplicationService-Encapsulation.cs
Last active December 28, 2021 19:36
DDD-ApplicationService-Encapsulation.cs
using System.Threading.Tasks;
using EncapsulationApi.DDD.DomainModels;
using EncapsulationApi.DDD.Repositories;
namespace EncapsulationApi.DDD.ApplicationServices
{
public class DomainModelApplicationService : IDomainModelApplicationService
{
private readonly IDomainModelRepository _domainModelRepository;
@domingoladron
domingoladron / Crappy-ATM-Machine-Class-Usage.cs
Last active December 28, 2021 06:02
Crappy-ATM-Machine-Class-Usage.cs
var atmMachine = new CrappyAtmMachine();
var amountToWithdraw = 20;
var curAccount = atmMachine.ThisJerksAccounts.Find(g => g.AccountNumber.Equals(accountId));
if(curAccount != null)
{
Console.WriteLine($"I checked my balance on account #{accountId}. The balance is now ${curAccount.Balance}");
if (curAccount.Balance < amountToWithdraw)
{
@domingoladron
domingoladron / Crappy-ATM-Machine-Class-Example.cs
Last active December 28, 2021 19:47
Crappy-ATM-Machine-Class-Example.cs
using System.Collections.Generic;
using AtmEncapsulationExample.AtmMachines.Good;
namespace AtmEncapsulationExample.AtmMachines.Crappy
{
/// <summary>
/// Our un-encapsulated ATM Machine
/// </summary>
public class CrappyAtmMachine
{
@domingoladron
domingoladron / ATM-Machine-Class-Usage.cs
Last active December 28, 2021 19:39
ATM-Machine-Class-Usage.cs
private static void CallGoodAtmMachine()
{
//Call a factory to get back our atm interface implementation
var atmMachine = AtmMachineFactory.GetAtmMachine();
atmMachine.Login(5555);
var balance = atmMachine.CheckBalance(accountId);
Console.WriteLine($"I checked my balance on account #{accountId}. The balance is now ${balance}");
@domingoladron
domingoladron / ATM-Machine-Class-Example.cs
Last active December 28, 2021 19:37
ATM-Machine-Class-Example.cs
using System.Collections.Generic;
using System.Linq;
namespace AtmEncapsulationExample.AtmMachines
{
/// <summary>
/// Our public interface to our ATM Machine
/// </summary>
public interface IAtmMachine
{
@domingoladron
domingoladron / get-widget-by-id.puml
Created June 1, 2020 23:29
get-widget-by-id.puml
@startuml
actor caller order 1
participant API order 2
participant WidgetAppService order 3
participant AuthorisationService order 4
participant WidgetRepository order 5
participant MoreDetailsWidgetRepository order 6
database WidgetDB order 7
boundary MoreDetailsAPI order 8
@domingoladron
domingoladron / aspnetcore.webapiconventions.controller.cs
Created May 23, 2020 00:05
aspnetcore.webapiconventions.controller.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace AspNetCore.Conventions.Controllers
{
[ApiController]
@domingoladron
domingoladron / aspnetcore.webapiconventions.newway.cs
Created May 22, 2020 23:48
aspnetcore.webapiconventions.newway.cs
[HttpGet]
[ApiConventionMethod(typeof(DefaultApiConventions),
nameof(DefaultApiConventions.Get))]
public async Task<ActionResult<IEnumerable<WeatherForecast>>> GetAsync()
{
var rng = new Random();
var notFound = false;
var response = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),