Last active
August 29, 2015 14:08
-
-
Save jmillikan/650eb3ec66eebd4a7b8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Error<T> | |
{ | |
public Func<T> Unfetched = () => { throw new Exception("Unfetched"); }; | |
} | |
static class Errors | |
{ | |
public static Error<string> String = new Error<string>(); | |
public static Error<float> Float = new Error<float>(); | |
} | |
class Person { | |
public Func<string> Name = Errors.String.Unfetched; | |
public Func<float> Age = Errors.Float.Unfetched; | |
public Func<int, bool> FetchById; | |
public Person() | |
{ | |
FetchById = (int id) => | |
{ | |
if (new Random().Next(0, 50) == 0) | |
{ | |
Name = Errors.String.Unfetched; | |
Age = Errors.Float.Unfetched; | |
return false; | |
} | |
var dataRow = new { Age = 20, Name = "Joe Blow" }; | |
Name = () => dataRow.Name; | |
Age = () => dataRow.Age; | |
return true; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment