コード例 #1
0
        public bool MergeByKey(OptionRefCollection incoming)
        {
            var combined = new List <OptionRef>(_members);

            foreach (OptionRef optionRef in incoming.Members)
            {
                var match = this.FindByKey(optionRef.Key);
                if (match == null)
                {
                    combined.Add(optionRef);
                }
                else
                {                   //now, if we don't have embedded xml and they do, take on theirs
                    if (match.EmbeddedXmlElements == null || match.EmbeddedXmlElements.Count == 0)
                    {
                        match.EmbeddedXmlElements = optionRef.EmbeddedXmlElements;
                    }
                    else if (optionRef.EmbeddedXmlElements.Count > 0)
                    {
                        return(false);                        //we don't know how to combine these
                    }
                }
            }
            _members.Clear();
            foreach (var optionRef in combined)
            {
                _members.Add(optionRef);
            }
            return(true);
        }
コード例 #2
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (!(obj is OptionRefCollection))
            {
                throw new ArgumentException("Can not compare to anything but OptionRefs.");
            }
            OptionRefCollection other = (OptionRefCollection)obj;
            int order = _members.Count.CompareTo(other.Members.Count);

            if (order != 0)
            {
                return(order);
            }
            for (int i = 0; i < _members.Count; i++)
            {
                order = _members[i].CompareTo(other.Members[i]);
                if (order != 0)
                {
                    return(order);
                }
            }
            return(0);
        }
コード例 #3
0
        public IPalasoDataObjectProperty Clone()
        {
            var clone = new OptionRefCollection();

            foreach (var memberToClone in _members)
            {
                clone._members.Add((OptionRef)memberToClone.Clone());
            }
            return(clone);
        }
コード例 #4
0
 public bool Equals(OptionRefCollection other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (!_members.SequenceEqual(other._members))
     {
         return(false);
     }
     return(true);
 }
コード例 #5
0
		public bool Equals(OptionRefCollection other)
		{
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			if (!_members.SequenceEqual(other._members)) return false;
			return true;
		}
コード例 #6
0
		public IPalasoDataObjectProperty Clone()
		{
			var clone = new OptionRefCollection();
			foreach (var memberToClone in _members)
			{
				clone._members.Add((OptionRef) memberToClone.Clone());
			}
			return clone;
		}
コード例 #7
0
		public bool MergeByKey(OptionRefCollection incoming)
		{
			var combined = new List<OptionRef>(_members);
			foreach (OptionRef optionRef in incoming.Members)
			{
				var match = this.FindByKey(optionRef.Key);
				if(match == null)
				{
					combined.Add(optionRef);
				}
				else
				{   //now, if we don't have embedded xml and they do, take on theirs
					if (match.EmbeddedXmlElements == null || match.EmbeddedXmlElements.Count == 0)
						match.EmbeddedXmlElements = optionRef.EmbeddedXmlElements;
					else if(optionRef.EmbeddedXmlElements.Count>0)
					{
						return false; //we don't know how to combine these
					}
				}
			}
			_members.Clear();
			foreach (var optionRef in combined)
			{
				_members.Add(optionRef);
			}
			return true;
		}