Guest User

Untitled

a guest
Nov 13th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. class FooRepo
  2. {
  3. public string ConnectionStringName { get; }
  4. public string SchemaName { get; }
  5. public string TableName { get; }
  6. public Dictionary<string, int> ColumnLengths { get; }
  7. public Dictionary<Type, SqlDbType> TypeMappings { get; }
  8.  
  9. // some queries...
  10. public IEnumerable<string> GetStrings(object param1) { ... }
  11. }
  12.  
  13. class Foo
  14. {
  15. public Foo() {}
  16.  
  17. public string Bar { get; private set; }
  18.  
  19. public string Qux { get; }
  20.  
  21. public class Builder
  22. {
  23. private Foo _foo = new Foo();
  24. private Builder() {}
  25.  
  26. public static Builder Create()
  27. {
  28. return new Builder();
  29. }
  30.  
  31. public Builder Bar(string bar)
  32. {
  33. _foo.Bar = bar;
  34. return this;
  35. }
  36.  
  37. public Foo ToFoo()
  38. {
  39. return new Foo()
  40. {
  41. Bar = _foo.Bar
  42. };
  43. }
  44. }
  45. }
  46.  
  47. var foo = Foo.Builder.Create().Bar("baz").ToFoo();
  48. var bar = foo.Bar;
  49.  
  50. var foo = new FooRepo(string connectionStringName, other parameters...);
  51. var bar = remute.With(foo, x => x.ConnectionStringName, "updated connection");
Add Comment
Please, Sign In to add comment