/// <summary> /// Import d'un service /// </summary> /// <param name="shape">The shape.</param> /// <param name="e">The <see cref="Microsoft.VisualStudio.Modeling.Diagrams.DiagramDragEventArgs"/> instance containing the event data.</param> internal static void OnDragDropOnLayer(NodeShape shape, DiagramDragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) { string txt = (string)e.Data.GetData(DataFormats.Text); using ( Transaction transaction = shape.ModelElement.Store.TransactionManager.BeginTransaction("Import interface")) { // On ne veut pas que les assistants soient appelés shape.ModelElement.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context. ContextInfo[StrategyManager.IgnoreStrategyWizards] = true; IImportInterfaceHelper importer = ServiceLocator.Instance.GetService <IImportInterfaceHelper>(); if (importer == null) { return; } if (importer.ImportOperations(shape.ModelElement as SoftwareLayer, null, txt)) { shape.RebuildShape(); transaction.Commit(); } } using ( Transaction transaction = shape.ModelElement.Store.TransactionManager.BeginTransaction("Arrange ports")) { LayerHelper.ArrangePorts(shape, typeof(ServiceContractShape)); transaction.Commit(); } } }
/// <summary> /// Import d'un service /// </summary> /// <param name="shape">The shape.</param> /// <param name="e">The <see cref="Microsoft.VisualStudio.Modeling.Diagrams.DiagramDragEventArgs"/> instance containing the event data.</param> /// <returns></returns> internal static bool OnDragDropOnPackage(NodeShape shape, DiagramDragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) { string txt = (string)e.Data.GetData(DataFormats.Text); using ( Transaction transaction = shape.ModelElement.Store.TransactionManager.BeginTransaction("Import entity")) { // On ne veut pas que les assistants soient appelés shape.ModelElement.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context. ContextInfo[StrategyManager.IgnoreStrategyWizards] = true; IImportEntityHelper importer = ServiceLocator.Instance.GetService <IImportEntityHelper>(); if (importer == null) { return(false); } if (importer.ImportProperties(shape.ModelElement as Package, null, txt)) { shape.RebuildShape(); transaction.Commit(); } } return(true); } return(false); }