PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/ResourceManagement.ObjectModel/RmAttributeChange.cs

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