src/Misc/EFTools/EntityDesign/VisualStudio/EFModelErrorTaskNavigator.cs
// <summary>
//     This will handle navigation for an ErrorTask
// </summary>
// <param name="sender">This should be an instance of ErrorTask and implement IEFErrorTask</param>
// <param name="arguments"></param>
This will handle navigation for an ErrorTask
This will handle navigation for an ErrorTask
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1614:ElementParameterDocumentationMustHaveText")]
        internal static void NavigateTo(Object sender, EventArgs arguments)
        {
            Debug.Assert(_dslDesignerOnNavigate != null, "DSL navigation delegate is null!");
            var task = sender as ErrorTask;
            if (task == null)
            {
                Debug.Fail("unable to cast sender to Task instance");
                return;
            }
            var efTask = task as IXmlModelErrorTask;
            if (efTask == null)
            {
                Debug.Fail("Unable to cast errorTask to IEFErrorTask");
                return;
            }
            if (String.IsNullOrEmpty(task.Document))
            {
                return;
            }
            var serviceProvider = efTask.ServiceProvider;
            var docDataObject = VSHelpers.GetDocData(serviceProvider, task.Document);
            if (docDataObject == null)
            {
                var uri = Utils.FileName2Uri(task.Document);
                if (Path.GetExtension(uri.LocalPath)
                    .Equals(EntityDesignArtifact.ExtensionEdmx, StringComparison.OrdinalIgnoreCase))
                {
                    var isArtifactDesignerSafe = IsUnloadedDocumentDesignerSafe(uri);
                    if (isArtifactDesignerSafe)
                    {
                        EscherDesignerNavigate(serviceProvider, uri, task);
                    }
                    else
                    {
                        var logicalView = VSConstants.LOGVIEWID_Primary;
                        VsShellUtilities.OpenDocumentWithSpecificEditor(
                            serviceProvider, uri.LocalPath,
                            CommonPackageConstants.xmlEditorGuid,
                            logicalView);
                        docDataObject = VSHelpers.GetDocData(serviceProvider, task.Document);
                        Debug.Assert(
                            docDataObject != null,
                            "attempt to open EDMX document in XML Editor - docDataObject should not be null");
                        VSHelpers.TextBufferNavigateTo(
                            serviceProvider, docDataObject, logicalView, task.Line,
                            task.Column);
                    }
                }
                else
                {
                    VsShellUtilities.OpenDocument(serviceProvider, task.Document);
                    docDataObject = VSHelpers.GetDocData(serviceProvider, task.Document);
                    Debug.Assert(
                        docDataObject != null,
                        "attempt to open non-EDMX document with primary Editor - docDataObject should not be null");
                    VSHelpers.TextBufferNavigateTo(
                        serviceProvider, docDataObject, VSConstants.LOGVIEWID_Primary,
                        task.Line, task.Column);
                }
            }
            else if (docDataObject is IEntityDesignDocData)
            {
                var uri = Utils.FileName2Uri(task.Document);
                var artifact = PackageManager.Package.ModelManager.GetArtifact(uri);
                if (artifact == null)
                {
                    Debug.Fail("didn't find artifact for document opened in Escher");
                    return;
                }
                if (artifact.IsDesignerSafe)
                {
                    EscherDesignerNavigate(serviceProvider, uri, task);
                }
                else
                {
                    var logicalView = VSConstants.LOGVIEWID_Primary;
                    VsShellUtilities.OpenDocumentWithSpecificEditor(
                        serviceProvider, uri.LocalPath,
                        CommonPackageConstants.xmlEditorGuid, logicalView);
                    docDataObject = VSHelpers.GetDocData(serviceProvider, task.Document);
                    Debug.Assert(
                        docDataObject != null,
                        "EDMX document already open - attempt to open in XML Editor resulted in null docDataObject");
                    VSHelpers.TextBufferNavigateTo(serviceProvider, docDataObject, logicalView, task.Line, task.Column);
                }
            }
            else
            {
                VSHelpers.TextBufferNavigateTo(
                    serviceProvider, docDataObject, VSConstants.LOGVIEWID_Primary, task.Line,
                    task.Column);
            }
        }
[ SuppressMessage ( " " , " " ) ] internal static void NavigateTo ( Object sender , EventArgs arguments ) { Debug . Assert ( _dslDesignerOnNavigate != null , " " ) ; var task = sender as ErrorTask ; if ( task == null ) { Debug . Fail ( " " ) ; return ; } var efTask = task as IXmlModelErrorTask ; if ( efTask == null ) { Debug . Fail ( " " ) ; return ; } if ( String . IsNullOrEmpty ( task . Document ) ) { return ; } var serviceProvider = efTask . ServiceProvider ; var docDataObject = VSHelpers . GetDocData ( serviceProvider , task . Document ) ; if ( docDataObject == null ) { var uri = Utils . FileName2Uri ( task . Document ) ; if ( Path . GetExtension ( uri . LocalPath ) . Equals ( EntityDesignArtifact . ExtensionEdmx , StringComparison . OrdinalIgnoreCase ) ) { var isArtifactDesignerSafe = IsUnloadedDocumentDesignerSafe ( uri ) ; if ( isArtifactDesignerSafe ) { EscherDesignerNavigate ( serviceProvider , uri , task ) ; } else { var logicalView = VSConstants . LOGVIEWID_Primary ; VsShellUtilities . OpenDocumentWithSpecificEditor ( serviceProvider , uri . LocalPath , CommonPackageConstants . xmlEditorGuid , logicalView ) ; docDataObject = VSHelpers . GetDocData ( serviceProvider , task . Document ) ; Debug . Assert ( docDataObject != null , " " ) ; VSHelpers . TextBufferNavigateTo ( serviceProvider , docDataObject , logicalView , task . Line , task . Column ) ; } } else { VsShellUtilities . OpenDocument ( serviceProvider , task . Document ) ; docDataObject = VSHelpers . GetDocData ( serviceProvider , task . Document ) ; Debug . Assert ( docDataObject != null , " " ) ; VSHelpers . TextBufferNavigateTo ( serviceProvider , docDataObject , VSConstants . LOGVIEWID_Primary , task . Line , task . Column ) ; } } else if ( docDataObject is IEntityDesignDocData ) { var uri = Utils . FileName2Uri ( task . Document ) ; var artifact = PackageManager . Package . ModelManager . GetArtifact ( uri ) ; if ( artifact == null ) { Debug . Fail ( " " ) ; return ; } if ( artifact . IsDesignerSafe ) { EscherDesignerNavigate ( serviceProvider , uri , task ) ; } else { var logicalView = VSConstants . LOGVIEWID_Primary ; VsShellUtilities . OpenDocumentWithSpecificEditor ( serviceProvider , uri . LocalPath , CommonPackageConstants . xmlEditorGuid , logicalView ) ; docDataObject = VSHelpers . GetDocData ( serviceProvider , task . Document ) ; Debug . Assert ( docDataObject != null , " " ) ; VSHelpers . TextBufferNavigateTo ( serviceProvider , docDataObject , logicalView , task . Line , task . Column ) ; } } else { VSHelpers . TextBufferNavigateTo ( serviceProvider , docDataObject , VSConstants . LOGVIEWID_Primary , task . Line , task . Column ) ; } }
This will handle navigation for an ErrorTask
This will handle navigation for an ErrorTask
// document wasn't opened // load a temp model to determine if the document is designer safe (only for EDMX, don't do this for converter docs) // this will open the document in escher // if the document cannot be displayed in the designer, so open it in the XML Editor and navigate to the error // document is not EDMX, so navigate to the document in the docdata's primary editor // attempt to get the artifact. This will return non-null if the document is open in either XML Editor or the designer // navigate to the correct place in the Escher designer // if the document cannot be displayed in the designer, so open it in the XML Editor and navigate to the error // document is opened, but not in Escher, so navigate to the document in the text editor
sender
Object
This should be an instance of ErrorTask and implement IEFErrorTask
This should be an instance of ErrorTask and implement IEFErrorTask
arguments
EventArgs
None