/Source/ResourceManagement.ObjectModel/RmAttributeChange.cs

# · C# · 103 lines · 94 code · 9 blank · 0 comment · 11 complexity · 756964464c215af3991e0c6fc8d26ab4 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Microsoft.ResourceManagement.ObjectModel
  6. {
  7. public class RmAttributeChange
  8. {
  9. private RmAttributeName name;
  10. private IComparable attributeValue;
  11. private RmAttributeChangeOperation operation;
  12. internal RmAttributeChange(RmAttributeName name, IComparable atomicValue, RmAttributeChangeOperation operation)
  13. {
  14. this.name = name;
  15. this.attributeValue = atomicValue;
  16. this.operation = operation;
  17. }
  18. public RmAttributeName Name
  19. {
  20. get
  21. {
  22. return this.name;
  23. }
  24. set
  25. {
  26. this.name = value;
  27. }
  28. }
  29. public IComparable Value
  30. {
  31. get
  32. {
  33. return this.attributeValue;
  34. }
  35. set
  36. {
  37. this.attributeValue = value;
  38. }
  39. }
  40. public RmAttributeChangeOperation Operation
  41. {
  42. get
  43. {
  44. return this.operation;
  45. }
  46. }
  47. public override bool Equals(object obj)
  48. {
  49. RmAttributeChange other = obj as RmAttributeChange;
  50. if (other == null)
  51. {
  52. return false;
  53. }
  54. if (this.Name == null)
  55. {
  56. return false;
  57. }
  58. if (this.Name.Equals(other.Name) == false)
  59. {
  60. return false;
  61. }
  62. if (this.Value == null)
  63. {
  64. return other.Value == null;
  65. }
  66. else
  67. {
  68. return this.Value.Equals(other.Value);
  69. }
  70. }
  71. public override int GetHashCode()
  72. {
  73. if (this.attributeValue != null)
  74. {
  75. return this.attributeValue.GetHashCode();
  76. }
  77. else
  78. {
  79. return base.GetHashCode();
  80. }
  81. }
  82. public override string ToString()
  83. {
  84. return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:{1}", this.Name.ToString(), this.Value.ToString());
  85. }
  86. }
  87. public enum RmAttributeChangeOperation
  88. {
  89. None = 0,
  90. Add = 1,
  91. Delete = 2,
  92. Replace = 3
  93. }
  94. }