예제 #1
0
        public static string Write(FileTemplate template, Location location, string inputModel)
        {
            var substitutions = new Substitutions();
            substitutions.Set("%MODEL%", inputModel);

            var path = location.CurrentFolder.AppendPath(inputModel.Split('.').Last() + template.Extension);
            var contents = template.Contents(substitutions);

            new FileSystem().WriteStringToFile(path, contents);

            return path;
        }
예제 #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 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;
        }
예제 #5
0
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("src");

            var project = CsProjFile.CreateAtSolutionDirectory("Foo", "src");
            project.Save();

            theLocation = new Location
            {
                Project = project
            };
        }