private static DiagramArtifact GetDiagramArtifactIfAvailable( ModelManager modelManager, Uri modelUri, XmlModelProvider xmlModelProvider) { var diagramFileName = modelUri.OriginalString + EntityDesignArtifact.ExtensionDiagram; return File.Exists(diagramFileName) ? new VSDiagramArtifact(modelManager, new Uri(diagramFileName), xmlModelProvider) : null; }
/// <summary> /// Constructs an EFArtifact for the passed in URI. /// Note: this class will call Dispose() on the provided (or created) XmlModelProvider when it Dispose(true) is called /// </summary> /// <param name="modelManager">A reference of ModelManager</param> /// <param name="uri">The URI to the EDMX file that this artifact will load</param> /// <param name="xmlModelProvider">If you pass null, then you must derive from this class and implement CreateModelProvider().</param> internal EFArtifact(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) : base(null, null) { Debug.Assert(modelManager != null, "You need to pass in a valid ModelManager reference"); Debug.Assert(uri != null, "You need to pass in a valid URI"); Debug.Assert(xmlModelProvider != null, "xmlModelProvider != null"); _modelManager = modelManager; _uri = uri; _xmlModelProvider = xmlModelProvider; }
public IList<EFArtifact> Create(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) { var artifact = new VSArtifact(modelManager, uri, xmlModelProvider); var artifacts = new List<EFArtifact> { artifact }; var diagramArtifact = GetDiagramArtifactIfAvailable(modelManager, uri, xmlModelProvider); if (diagramArtifact != null) { artifact.DiagramArtifact = diagramArtifact; artifacts.Add(diagramArtifact); } return artifacts; }
/// <summary> /// Constructs an EntityDesignArtifact for the passed in URI /// </summary> /// <param name="modelManager">A reference of ModelManager</param> /// <param name="uri">The URI to the EDMX file that this artifact will load</param> /// <param name="xmlModelProvider">If you pass null, then you must derive from this class and implement CreateModelProvider().</param> internal EntityDesignArtifact(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) : base(modelManager, uri, xmlModelProvider) { }
// <summary> // Creates an instance of an EFArtifact for use inside Visual Studio // </summary> // <param name="modelManager">A reference of ModelManager</param> // <param name="uri">The URI to the EDMX file that this artifact will load</param> // <param name="xmlModelProvider">We are ignoring this parameter, sending null to base class so that it will call CreateModelProvider()</param> internal VSArtifact(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) : base(modelManager, uri, xmlModelProvider) { }
internal EFArtifactHelper(ModelManager modelManager) { Debug.Assert(modelManager != null, "modelManager must not be null."); _modelManager = modelManager; }
private static EFArtifact GetArtifactForValidation(Uri uri, IVsHierarchy hierarchy, ModelManager modelManager) { IServiceProvider oleServiceProvider = null; var modelListener = PackageManager.Package.ModelChangeEventListener; hierarchy.GetSite(out oleServiceProvider); System.IServiceProvider sp = new ServiceProvider(oleServiceProvider); var escherDocData = VSHelpers.GetDocData(sp, uri.LocalPath) as IEntityDesignDocData; EFArtifact artifact = null; // // If we opened the document with Escher, then use the XmlEditor's xlinq tree // If we opened the document with the xml editor, but not escher, then // we don't want to use the XmlEditor's xlinq tree, because then we would be receiving events when // the document changes, and we currently don't support that. // if (escherDocData != null) { artifact = PackageManager.Package.ModelManager.GetNewOrExistingArtifact( uri, new VSXmlModelProvider(PackageManager.Package, PackageManager.Package)); if (modelListener != null) { modelListener.OnBeforeValidateModel(VSHelpers.GetProject(hierarchy), artifact, true); } } else { if (Path.GetExtension(uri.LocalPath).Equals(EntityDesignArtifact.ExtensionEdmx, StringComparison.OrdinalIgnoreCase)) { // no doc data exists for this document, so load it into a temp model manager that can be disposed of when we're done. // Using the LoaderBasedXmlModelProvider will let us catch XML scanner and parser errors (the xml editor will try to // recover from these, and we won't know that the problem occurred. artifact = modelManager.GetNewOrExistingArtifact(uri, new StandaloneXmlModelProvider(PackageManager.Package)); if (modelListener != null) { modelListener.OnBeforeValidateModel(VSHelpers.GetProject(hierarchy), artifact, true); } } } return artifact; }
/// <summary> /// Factory method for EntityDesignArtifact. /// Note that this method will not create DiagramArtifact. /// Please use VSArtifactFactory instead if DiagramArtifact needs to be created and loaded. /// </summary> public IList <EFArtifact> Create(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) { return(new List <EFArtifact> { new EntityDesignArtifact(modelManager, uri, xmlModelProvider) }); }
/// <summary> /// Constructs an DiagramArtifact for the passed in URI /// </summary> /// <param name="modelManager">A reference of ModelManager</param> /// <param name="uri">The Diagram File URI</param> /// <param name="xmlModelProvider">If you pass null, then you must derive from this class and implement CreateModelProvider().</param> internal DiagramArtifact(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) : base(modelManager, uri, xmlModelProvider) { }
protected virtual void OnHandleXmlModelTransactionCompleted( object sender, XmlTransactionEventArgs xmlTransactionEventArgs, bool isUndoOrRedo, out EfiChangeGroup changeGroup) { // If this is an undo/redo XML transaction there is no EfiTransaction, thus the artifact will not // be made dirty as necessary. We will have to do it manually here. var efiTransaction = xmlTransactionEventArgs.Transaction.UserState as EfiTransaction; if (efiTransaction == null && isUndoOrRedo) { Artifact.IsDirty = true; } // When an XML transaction completes it could either be a normal, undo, or redo transaction. // In all cases we will need to clear the "validity" of the artifact so that any successive // validations will not short-circuit. // Ideally we can skip this in the event of any major error that causes the reloading // of the artifact but we'll be safe. SetValidityDirtyForErrorClass(ErrorClass.All, true); // the change group to send back to the caller changeGroup = null; // if the transaction is aborting, drop and reload if (xmlTransactionEventArgs.Transaction.Status == XmlTransactionStatus.Aborted) { ReloadArtifact(); return; } if (efiTransaction != null) { changeGroup = ProcessDesignerChange(xmlTransactionEventArgs, efiTransaction); if (changeGroup != null) { ModelManager.RecordChangeGroup(changeGroup); } } else { // TODO: when we want SxS again, we should handle these operations in addition to undo/redo if (isUndoOrRedo) { try { changeGroup = ProcessUndoRedoChanges(xmlTransactionEventArgs); if (changeGroup != null) { ModelManager.RecordChangeGroup(changeGroup); // we have to manually route the change groups here because we can't rely on ProcessUndoRedoChange to do it since nothing // gets updated in the Xml Model ModelManager.RouteChangeGroups(); } } catch (ChangeProcessingFailedException) { ReloadArtifact(); } catch (Exception e) { Debug.Fail("Unexpected exception caught while processing undo/redo", e.Message); ReloadArtifact(); } } } }
/// <summary> /// Factory method for EntityDesignArtifact. /// Note that this method will not create DiagramArtifact. /// Please use VSArtifactFactory instead if DiagramArtifact needs to be created and loaded. /// </summary> public IList<EFArtifact> Create(ModelManager modelManager, Uri uri, XmlModelProvider xmlModelProvider) { return new List<EFArtifact> { new EntityDesignArtifact(modelManager, uri, xmlModelProvider) }; }