Exemplo n.º 1
0
		/// <summary></summary>
		public virtual void HandleCopyCommand(Slice newSlice, string label)
		{
			CheckDisposed();

			var origObj = GetObjectForMenusToOperateOn();
			if (origObj == null)
				throw new ConfigurationException("OriginalSlice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be moved to a copy of its owner.", m_configurationNode);

			var newObj = newSlice.GetObjectForMenusToOperateOn();
			if (newObj == null)
				throw new ConfigurationException("NewSlice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be moved to a copy of its owner.", m_configurationNode);

			if (origObj is ICloneableCmObject)
			{
				string undoMsg = String.Format("Undo {0}", label);
				string redoMsg = String.Format("Redo {0}", label);
				UndoableUnitOfWorkHelper.Do(undoMsg, redoMsg, m_cache.ActionHandlerAccessor,
					() => { ((ICloneableCmObject)origObj).SetCloneProperties(newObj); });
			}
			else
			{
				throw new NotImplementedException(origObj.ClassName + " is not set up for copying!");
			}
		}