diff options
Diffstat (limited to 'main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs')
-rw-r--r-- | main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs index f24df75a1c..2c437a46ba 100644 --- a/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs +++ b/main/src/addins/AspNet/Commands/AddViewFromControllerCommandHandler.cs @@ -28,6 +28,7 @@ using System; using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
using MonoDevelop.AspNet.Projects;
+using MonoDevelop.Projects;
namespace MonoDevelop.AspNet.Commands
{
@@ -41,20 +42,16 @@ namespace MonoDevelop.AspNet.Commands protected override void Run ()
{
var doc = IdeApp.Workbench.ActiveDocument;
- var project = (AspNetAppProject)doc.Project;
- var currentLocation = doc.Editor.Caret.Location;
+ var project = (DotNetProject)doc.Project;
- string controllerName = doc.ParsedDocument.GetTopLevelTypeDefinition (currentLocation).Name;
- int pos = controllerName.LastIndexOf ("Controller", StringComparison.Ordinal);
- if (pos > 0)
- controllerName = controllerName.Remove (pos);
+ var method = MethodDeclarationAtCaret.Create (doc);
+ string controllerName = method.GetParentMvcControllerName ();
+ string path = doc.FileName.ParentDirectory.ParentDirectory.Combine ("Views", controllerName);
- string path = doc.FileName.ParentDirectory.ParentDirectory.Combine ("Views", controllerName); - string actionName = doc.ParsedDocument.GetMember (currentLocation).Name;
- AddView (project, path, actionName);
+ AddView (project, path, method.Name);
}
- public static void AddView (AspNetAppProject project, string path, string name)
+ public static void AddView (DotNetProject project, string path, string name)
{
var provider = project.LanguageBinding.GetCodeDomProvider ();
if (provider == null)
@@ -127,7 +124,7 @@ namespace MonoDevelop.AspNet.Commands if (System.IO.File.Exists (outputFile)) {
project.AddFile (outputFile);
- IdeApp.ProjectOperations.Save (project);
+ IdeApp.ProjectOperations.SaveAsync (project);
}
}
}
|