/// <summary> /// Perform the copy operation of an <see cref="ElementDefinition"/> /// </summary> /// <param name="elementDefinition">The <see cref="ElementDefinition"/> to copy</param> /// <param name="targetIteration">The target container</param> public async Task Copy(ElementDefinition elementDefinition, bool areUsagesCopied) { var iterationClone = (Iteration)elementDefinition.Container.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(iterationClone); var transaction = new ThingTransaction(transactionContext, iterationClone); var clone = elementDefinition.Clone(true); clone.Iid = Guid.NewGuid(); clone.Name += CopyAffix; if (!areUsagesCopied) { clone.ContainedElement.Clear(); } this.ResolveReferences(elementDefinition, clone); iterationClone.Element.Add(clone); transaction.CopyDeep(clone); await this.session.Write(transaction.FinalizeTransaction()); }