private static string createText(ViewInput input, Location location) { var template = input.UrlFlag.IsEmpty() ? NakedModel : UrlModel; var builder = new StringBuilder(template); builder.Replace("%NAMESPACE%", location.Namespace); builder.Replace("%CLASS%", input.Name); if (input.UrlFlag.IsNotEmpty()) { builder.Replace("%URL%", "\"" + input.UrlFlag + "\""); } return builder.ToString(); }
private static string createText(ViewInput input, Location location) { var template = input.UrlFlag.IsEmpty() ? NakedModel : UrlModel; var builder = new StringBuilder(template); builder.Replace("%NAMESPACE%", location.Namespace); builder.Replace("%CLASS%", input.Name); if (input.UrlFlag.IsNotEmpty()) { builder.Replace("%URL%", "\"" + input.UrlFlag + "\""); } return(builder.ToString()); }
public void SetUp() { new FileSystem().DeleteDirectory("MyLib"); new FileSystem().CreateDirectory("MyLib"); theLocation = new Location { Namespace = "MyLib.A.B", Project = CsProjFile.CreateAtSolutionDirectory("MyLib", "MyLib"), RelativePath = "A/B" }; theViewInput = new ViewInput { Name = "MyModel", UrlFlag = null }; theFile = ViewModelBuilder.BuildCodeFile(theViewInput, theLocation); }
public static void BuildView(ViewInput input) { Location location = ProjectFinder.DetermineLocation(Environment.CurrentDirectory); var template = FileTemplate.Find(location, input.TemplateFlag); ViewModelBuilder.BuildCodeFile(input, location); var modelName = location.Namespace + "." + input.Name; var path = ViewBuilder.Write(template, location, modelName); var viewPath = path.PathRelativeTo(location.ProjectFolder()).Replace('\\', '/'); location.Project.Add(new Content(viewPath)); location.Project.Save(); if (input.OpenFlag) { EditorLauncher.LaunchFile(path); } }
public static CodeFile BuildCodeFile(ViewInput input, Location location) { var filename = Path.GetFileNameWithoutExtension(input.Name) + ".cs"; var path = location.Project.ProjectDirectory.AppendPath(location.RelativePath, filename); var text = createText(input, location); new FileSystem().WriteStringToFile(path, text); var file = new CodeFile(location.RelativePath.AppendPath(filename)); location.Project.Add(file); location.Project.Save(); if (input.OpenFlag) { EditorLauncher.LaunchFile(path); } return file; }
public static CodeFile BuildCodeFile(ViewInput input, Location location) { var filename = Path.GetFileNameWithoutExtension(input.Name) + ".cs"; var path = location.Project.ProjectDirectory.AppendPath(location.RelativePath, filename); var text = createText(input, location); new FileSystem().WriteStringToFile(path, text); var file = new CodeFile(location.RelativePath.AppendPath(filename)); location.Project.Add(file); location.Project.Save(); if (input.OpenFlag) { EditorLauncher.LaunchFile(path); } return(file); }