Spring.Objects.Factory.Config.ManagedList.Merge C# (CSharp) Метод

Merge() публичный Метод

Merges the current value set with that of the supplied object.
The supplied object is considered the parent, and values in the callee's value set must override those of the supplied object.
If the supplied parent is null If merging is not enabled for this instance, /// (i.e. MergeEnabled equals false.
public Merge ( object parent ) : object
parent object The parent object to merge with
Результат object
        public object Merge(object parent)
        {
            if (!this.mergeEnabled)
            {
                throw new InvalidOperationException(
                    "Not allowed to merge when the 'MergeEnabled' property is set to 'false'");
            }
            if (parent == null)
            {
                return this;
            }
            IList plist = parent as IList;
            if (plist == null)
            {
                throw new InvalidOperationException("Cannot merge with object of type [" + parent.GetType() + "]");
            }
            IList merged = new ManagedList();
            foreach (object element in plist)
            {
                merged.Add(element);
            }
            foreach (object o in this)
            {
                merged.Add(o);
            }
            return merged;
        }
    }

Usage Example

Пример #1
0
 public void MergeWithNonCompatibleParentType()
 {
     ManagedList child = new ManagedList();
     child.Add("one");
     child.MergeEnabled = true;
     child.Merge("hello");
 }
All Usage Examples Of Spring.Objects.Factory.Config.ManagedList::Merge