Skip to content

Instantly share code, notes, and snippets.

View jameshulse's full-sized avatar

James Hulse jameshulse

View GitHub Profile
@jameshulse
jameshulse / MapExample.cs
Last active December 16, 2015 14:10
Example Automapper API to determine changes made from mapping
var person = new Person(name: "James", age: 27);
var update = new PersonUpdate { age = 28 };
var changes = Map.MapWithChanges(update, person); // Theoretical API
if(changes.Any())
_db.Save(person);
@jameshulse
jameshulse / gist:7035070
Created October 18, 2013 01:26
Lazy dictionary
public class LazyDictionary<TKey, TValue>
{
private readonly Func<TKey, TValue> _factory;
private readonly Dictionary<TKey, TValue> _cache;
public LazyDictionary(Func<TKey, TValue> factory)
{
_factory = factory;
_cache = new Dictionary<TKey, TValue>();
}