Exemplo n.º 1
0
 public ImportJob(ImportRecursionMode import_mode, ImportOverwriteMode overwrite_mode)
     : this()
 {
     ImportMode    = import_mode;
     OverwriteMode = overwrite_mode;
     ImportMap     = new Dictionary <Element, Element>();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Copies another Datamodel's <see cref="Element"/> into this one.
        /// </summary>
        /// <remarks>The return value will be owned by this Datamodel. It can be:
        /// 1. foreign_element. This is the case when foreign_element has no owner and no Element with the same ID exists in this Datamodel.
        /// 2. An existing Element owned by this Datamodel with the same ID as foreign_element.
        /// 3. A copy of foreign_element. This is the case when foreign_element already had an owner and a corresponding Element was not found in this Datamodel.</remarks>
        /// <param name="foreign_element">The Element to import. Must be owned by a different Datamodel.</param>
        /// <param name="import_mode">How to respond when foreign_element references other foreign Elements.</param>
        /// <param name="overwrite_mode">How to respond when the ID of a foreign Element is already in use in this Datamodel.</param>
        /// <returns>foreign_element, a local Element, or a new copy of foreign_element. See Remarks for more details.</returns>
        /// <exception cref="ArgumentNullException">Thrown if foreign_element is null.</exception>
        /// <exception cref="ElementOwnershipException">Thrown if foreign_element is already owned by this Datamodel.</exception>
        /// <exception cref="IndexOutOfRangeException">Thrown when the maximum number of Elements allowed in a Datamodel has been reached.</exception>
        /// <seealso cref="Element.Stub"/>
        /// <seealso cref="Element.ID"/>
        public Element ImportElement(Element foreign_element, ImportRecursionMode import_mode, ImportOverwriteMode overwrite_mode)
        {
            if (foreign_element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (foreign_element.Owner == this)
            {
                throw new ElementOwnershipException("Element is already a part of this Datamodel.");
            }

            return(ImportElement_internal(foreign_element, new ImportJob(import_mode, overwrite_mode)));
        }