Created
November 19, 2013 21:34
-
-
Save JimmyHoffa/7552976 to your computer and use it in GitHub Desktop.
random ass guess example of combinator repository
This file contains hidden or 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
public class PersonModel | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public int Age { get; set; } | |
public bool Amazing { get; set; } | |
public PersonModel OnlyFriend { get; set; } | |
} | |
public delegate PersonModel Person(); | |
public class PersonRepository | |
{ | |
public IList<Person> GetByAge(int age) | |
{ | |
return () => //code that finds all people for the age variable | |
} | |
public Person GetById(int id) | |
{ | |
return () => // code that finds the person with this id | |
} | |
public Person SetFriend(Person personWhoseFriendToSet, Person friend) | |
{ | |
return () => | |
{ | |
var person = personWhoseFriendToSet(); | |
person.OnlyFriend = friend(); | |
return person; | |
}; | |
} | |
public Person TerminatePerson(Person personToTerminate) | |
{ | |
return () => // code that deletes the person returned by Person() | |
} | |
public Person SavePerson(Person personToSave) | |
{ | |
return () => // code that saves the person to the DB | |
} | |
} | |
public class AmazingSoftware | |
{ | |
public static Wow() | |
{ | |
var repo = new PersonRepository(); | |
Person someoneWhoWasTerminated = repo.TerminatePerson(repo.GetById(42)); | |
repo.SetFriend(repo.SavePerson(someoneWhoWasTerminated), repo.SavePerson(() => new PersonModel())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment