Skip to content

Instantly share code, notes, and snippets.

//
// LBTagSync.m
// Life Blog
//
// Created by Sully on 3/1/14.
// Copyright (c) 2014 AllocateThis! Studios. All rights reserved.
//
#import "LBTagSync.h"
#import "LBTagRepository.h"
@scionwest
scionwest / AccountRepo.cs
Created December 20, 2014 08:02
Repository
public async Task<OperationResult> CreateUser(string username, string email, string password)
{
// We have to convert the keys to camelcase for Parse.
// Regular expressions weren't working. Need to revist them as this is
// creating a large of garbage.
//var userData = new
//{
// username = username.Substring(0, 1).ToLower() + username.Substring(1),
// email = email.Substring(0, 1).ToLower() + email.Substring(1),
// password = password,
@scionwest
scionwest / EngineTimer.cs
Created January 2, 2015 22:59
Engine Timer
//-----------------------------------------------------------------------
// <copyright file="EngineTimer.cs" company="Sully">
// Copyright (c) Johnathon Sullinger. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Mud.Engine.Runtime.Core
{
using System;
using System.Diagnostics;
using System.Threading;
System.InvalidOperationException was unhandled
Message: An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.CodeAnalysis.Workspaces.dll
Additional information: Unexpected value 'IdentifierName' of type 'Microsoft.CodeAnalysis.CSharp.SyntaxKind'
@scionwest
scionwest / gist:752ab399db55edb40de8
Last active August 29, 2015 14:12
Unit Test w/ Mocks
[TestClass]
public class AccountServiceTests
{
private IAccountService accountService;
[TestInitialize]
public void Setup()
{
// Build our User Repository mock for the account service to use.
var userRepositoryMock = new Mock<IUserRepository>();
private static Dictionary<string, Type> cachedStateNames = new Dictionary<string, Type>();
public static TimeOfDayState CreateStateByName(string name, TimeOfDay stateTime)
{
IEnumerable<Type> timeOfDayStateTypes = typeof(TimeOfDayState).GetTypeInfo().Assembly.ExportedTypes
.Where(type => type.GetTypeInfo().BaseType == typeof(TimeOfDayState));
if (cachedStateNames.Count == 0)
{
foreach(Type type in timeOfDayStateTypes)
private List<Func<Task>> ShutdownCallbacks = new List<Func<Task>>();
public void RegisterShutdownCallback(Func<Task> callback)
{
this.ShutdownCallbacks.Add(callback);
}
public async Task Shutdown()
{
var callbackTasks = new List<Task>();
private static void RegisterContainerTypes()
{
var builder = new ContainerBuilder();
builder.RegisterType<LoggingService>().As<ILoggingService>();
builder.RegisterType<FileStorageService>().As<IFileStorageService>();
// Engine runtime types
builder.RegisterType<DefaultGame>().As<DefaultGame>();
builder.RegisterType<WorldService>().As<IWorldService>();
public class World
{
public World(IGame game, IWorldService service)
{
game.RegisterShutdown(async () => service.SaveWorld(this));
}
}
public static class Program
{
public interface IMessage
{
T GetContent<T>() where T : class;
}
public abstract class MessageBase<TContentType> : IMessage where TContentType : class
{
TContentType Content { get; }
public abstract TContentType GetContent<ContentType>();