예제 #1
0
        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();
        }
예제 #2
0
        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());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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;
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
        }