Skip to content

Instantly share code, notes, and snippets.

@JimmyHoffa
Created November 19, 2013 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JimmyHoffa/7552976 to your computer and use it in GitHub Desktop.
Save JimmyHoffa/7552976 to your computer and use it in GitHub Desktop.
random ass guess example of combinator repository
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