basic example of removing switch statement and instead using OO to have implementations that represent each type
public class Entity
{
public string Type { get; set; }
public int GetNewValueBasedOnType(int newValue)
{
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Data.SqlClient; | |
using System.Data; | |
namespace blobstoretest | |
{ |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string path = args[0]; | |
Console.WriteLine("trying path: " + path); | |
if (Directory.Exists(path)) | |
Directory.GetFiles(path).ToList().ForEach(s => Console.WriteLine(s)); |
Windows Powershell | |
-- to remove gems | |
gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ } | |
-- add back important ones | |
gem install bundler json minitest rake rdoc |
[AllowAnonymous] | |
[HttpGet] | |
[Route("confirm-signup", Name = "ConfirmSignUpRoute")] | |
public async Task<IHttpActionResult> ConfirmSignUp(string userId = "", string code = "") | |
{ | |
IdentityResult confirmEmailResult = await this.AppUserManager.ConfirmEmailAsync(userId, code); | |
if (!confirmEmailResult.Succeeded) | |
{ | |
return GetErrorResult(confirmEmailResult); |
// base class | |
[BsonDiscriminator(RootClass = true)] | |
[BsonKnownTypes(typeof(Cat), typeof(Dog))] | |
public abstract class Animal | |
{ | |
public string id { get; set; } | |
public string name { get; set; } | |
public int age { get; set; } | |
} |
.wrapper { | |
.transition(@property: opacity, @duration: .2s, @timing: ease-in-out); | |
.opacity (@opacity: 1); | |
&.hide { | |
.opacity (@opacity: 0); | |
} | |
} | |
.wrapper { | |
& > * { |
It is simplest, thread-safe solution with lazy initialization, that everyone can understand.
Example pull from here https://rubikscode.net/2017/06/11/different-ways-to-implement-singleton-in-net-and-make-people-hate-you-along-the-way/ But also see this Jon Skeets http://csharpindepth.com/Articles/General/Singleton.aspx#lazy