コード例 #1
0
        protected override void Run()
        {
            var    doc            = IdeApp.Workbench.ActiveDocument;
            var    method         = MethodDeclarationAtCaret.Create(doc);
            string controllerName = method.GetParentMvcControllerName();

            var baseDirectory = doc.FileName.ParentDirectory.ParentDirectory;

            string actionName       = method.Name;
            var    viewFoldersPaths = new [] {
                baseDirectory.Combine("Views", controllerName),
                baseDirectory.Combine("Views", "Shared")
            };
            var viewExtensions = new [] { ".aspx", ".cshtml" };

            foreach (var folder in viewFoldersPaths)
            {
                foreach (var ext in viewExtensions)
                {
                    var possibleFile = folder.Combine(actionName + ext);
                    if (File.Exists(possibleFile))
                    {
                        IdeApp.Workbench.OpenDocument(possibleFile, doc.Project);
                        return;
                    }
                }
            }

            MessageService.ShowError(GettextCatalog.GetString("Matching view cannot be found."));
        }
コード例 #2
0
        public static void Update(CommandInfo info)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null || doc.Owner == null || doc.DocumentContext.ParsedDocument == null)
            {
                info.Enabled = info.Visible = false;
                return;
            }
            var aspFlavor = doc.Owner.GetService <AspNetAppProjectFlavor> ();

            if (aspFlavor == null || !aspFlavor.IsAspMvcProject)
            {
                info.Enabled = info.Visible = false;
                return;
            }

            var method = MethodDeclarationAtCaret.Create(doc);

            if (method.IsMethodFound && method.IsParentMvcController() && method.IsMvcViewMethod())
            {
                return;
            }

            info.Enabled = info.Visible = false;
        }
コード例 #3
0
        protected override void Run()
        {
            var doc     = IdeApp.Workbench.ActiveDocument;
            var project = (DotNetProject)doc.Owner;

            var    method         = MethodDeclarationAtCaret.Create(doc);
            string controllerName = method.GetParentMvcControllerName();
            string path           = doc.FileName.ParentDirectory.ParentDirectory.Combine("Views", controllerName);

            AddView(project, path, method.Name);
        }