Guest User

Untitled

a guest
Apr 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. namespace Entities
  2. {
  3. using System;
  4. using System.Collections;
  5. // using System.Diagnostics.Contracts;
  6.  
  7. public class PersonValueObject {
  8. private string[] _columns = { "firstname", "lastname" };
  9. private Hashtable _values;
  10.  
  11. public PersonValueObject () {
  12. Console.WriteLine("person value object init");
  13.  
  14. this._values = new Hashtable();
  15.  
  16. for (int x = 0; x < _columns.Length; x++) {
  17. this[_columns[x]] = "";
  18. }
  19. }
  20.  
  21. public string this[string key] {
  22. get {
  23. // Contract.Requires(key != null);
  24. // Contract.Requires(_values.ContainsKey(key));
  25.  
  26. return (string) _values[key];
  27. }
  28. set {
  29. // Contract.Requires(key != null);
  30. // Contract.Requires(_values.ContainsKey(key));
  31. // Contract.Requires(value != null);
  32.  
  33. _values[key] = (string) value;
  34. }
  35. }
  36.  
  37. public void SetValues(Hashtable values) {
  38. IDictionaryEnumerator enumerator = values.GetEnumerator();
  39.  
  40. while (enumerator.MoveNext()) {
  41. this[(string) enumerator.Key] = (string) enumerator.Value;
  42. }
  43. }
  44.  
  45. public Hashtable GetValues() {
  46. return _values;
  47. }
  48. }
  49. }
Add Comment
Please, Sign In to add comment