Ejemplo n.º 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();
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }