Esempio n. 1
0
        public override bool Equals(object obj)
        {
            RmAttributeValue other = obj as RmAttributeValue;

            if (other == null)
            {
                return(false);
            }
            lock (this.values)
            {
                lock (other.values)
                {
                    if (this.values.Count != other.values.Count)
                    {
                        return(false);
                    }
                    this.values.Sort();
                    other.values.Sort();
                    for (int i = 0; i < this.values.Count; i++)
                    {
                        if (this.values[i].Equals(other.values[i]) == false)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            RmResource other = obj as RmResource;

            if (other == null)
            {
                return(false);
            }
            else
            {
                if (this.attributes.Count != other.attributes.Count)
                {
                    return(false);
                }
                foreach (KeyValuePair <RmAttributeName, RmAttributeValue> item in this.attributes)
                {
                    RmAttributeValue otherValue = null;
                    other.TryGetValue(item.Key, out otherValue);
                    if (otherValue == null)
                    {
                        return(false);
                    }
                    if (item.Value.Equals(otherValue) == false)
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
Esempio n. 3
0
 public void BeginChanges()
 {
     EnsureNotDisposed();
     lock (rmObject.attributes)
     {
         this.originalAttributes = new Dictionary <RmAttributeName, RmAttributeValue>();
         foreach (RmAttributeName key in rmObject.attributes.Keys)
         {
             this.originalAttributes[key] = new RmAttributeValue();
             RmAttributeValue value = rmObject.attributes[key];
             this.originalAttributes[key] = value.Clone() as RmAttributeValue;
         }
     }
 }
Esempio n. 4
0
        private static IList <RmAttributeChange> GetDifference(Dictionary <RmAttributeName, RmAttributeValue> attributes1, Dictionary <RmAttributeName, RmAttributeValue> attributes2)
        {
            IList <RmAttributeChange> changedAttributes = new List <RmAttributeChange>();

            foreach (KeyValuePair <RmAttributeName, RmAttributeValue> item1 in attributes1)
            {
                if (attributes2.ContainsKey(item1.Key) == false)
                {
                    foreach (IComparable value1 in item1.Value.Values)
                    {
                        changedAttributes.Add(new RmAttributeChange(item1.Key, value1, RmAttributeChangeOperation.Add));
                    }
                }
                else
                {
                    RmAttributeValue rmValue2 = attributes2[item1.Key];
                    foreach (IComparable value1 in item1.Value.Values)
                    {
                        if (rmValue2.Values.Contains(value1) == false)
                        {
                            changedAttributes.Add(new RmAttributeChange(item1.Key, value1, RmAttributeChangeOperation.Add));
                        }
                    }
                    foreach (IComparable value2 in rmValue2.Values)
                    {
                        if (item1.Value.Values.Contains(value2) == false)
                        {
                            changedAttributes.Add(new RmAttributeChange(item1.Key, value2, RmAttributeChangeOperation.Delete));
                        }
                    }
                }
            }
            foreach (KeyValuePair <RmAttributeName, RmAttributeValue> item2 in attributes2)
            {
                if (attributes1.ContainsKey(item2.Key) == false)
                {
                    foreach (IComparable value2 in item2.Value.Values)
                    {
                        changedAttributes.Add(new RmAttributeChange(item2.Key, value2, RmAttributeChangeOperation.Delete));
                    }
                }
            }
            return(changedAttributes);
        }
Esempio n. 5
0
        public object Clone()
        {
            RmAttributeValue newValue = new RmAttributeValue();

            newValue.values = new List <IComparable>();
            foreach (IComparable value in this.values)
            {
                ICloneable cloneValue = value as ICloneable;
                if (cloneValue == null)
                {
                    newValue.values.Add(value);
                }
                else
                {
                    IComparable cloneInsert = cloneValue.Clone() as IComparable;
                    if (cloneInsert == null)
                    {
                        throw new InvalidOperationException("A comparable, when cloned, returned a non-comparable: " + cloneValue.ToString());
                    }
                    newValue.values.Add(cloneInsert);
                }
            }
            return(newValue);
        }