Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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