Esempio n. 1
0
 public IEnumerable <MvcViewTextTemplate> GetMvcViewTextTemplates(MvcTextTemplateCriteria templateCriteria)
 {
     foreach (string templateFileName in GetMvcViewTemplateFileNamesInFolder(templateCriteria))
     {
         yield return(new MvcViewTextTemplate(templateFileName));
     }
 }
 public MvcViewTextTemplateFileName(
     string textTemplatesRootDirectory,
     MvcTextTemplateCriteria templateCriteria)
     : base(textTemplatesRootDirectory, templateCriteria)
 {
     this.folder = new MvcAddViewTextTemplateFolder(templateCriteria);
 }
Esempio n. 3
0
 public MvcTextTemplateFileName(
     string textTemplatesRootFolder,
     MvcTextTemplateCriteria templateCriteria)
 {
     this.textTemplatesRootFolder = textTemplatesRootFolder;
     this.templateCriteria        = templateCriteria;
 }
		public MvcViewTextTemplateFileName(
			string textTemplatesRootDirectory,
			MvcTextTemplateCriteria templateCriteria)
			: base(textTemplatesRootDirectory, templateCriteria)
		{
			this.folder = new MvcAddViewTextTemplateFolder(templateCriteria);
		}
		public MvcTextTemplateFileName(
			string textTemplatesRootFolder,
			MvcTextTemplateCriteria templateCriteria)
		{
			this.textTemplatesRootFolder = textTemplatesRootFolder;
			this.templateCriteria = templateCriteria;
		}
Esempio n. 6
0
        public IEnumerable <MvcControllerTextTemplate> GetMvcControllerTextTemplates(MvcTextTemplateCriteria templateCriteria)
        {
            string templateFileName = GetDefaultMvcControllerTextTemplateFileName(templateCriteria);

            yield return(CreateEmptyControllerTemplate(templateFileName));

            yield return(CreateEmptyReadWriteControllerTemplate(templateFileName));
        }
        List <MvcControllerTextTemplate> GetControllerTemplatesFromRepository()
        {
            var criteria = new MvcTextTemplateCriteria()
            {
                TemplateLanguage = GetTemplateLanguage()
            };

            return(textTemplateRepository.GetMvcControllerTextTemplates(criteria).ToList());
        }
		string GetDefaultMvcControllerTextTemplateFileName(MvcTextTemplateCriteria templateCriteria)
		{
			var defaultControllerTemplateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = templateCriteria.TemplateLanguage,
				TemplateName = "Controller",
				TemplateType = templateCriteria.TemplateType
			};
			return GetMvcControllerTextTemplateFileName(defaultControllerTemplateCriteria);
		}
Esempio n. 9
0
        string GetDefaultMvcControllerTextTemplateFileName(MvcTextTemplateCriteria templateCriteria)
        {
            var defaultControllerTemplateCriteria = new MvcTextTemplateCriteria()
            {
                TemplateLanguage = templateCriteria.TemplateLanguage,
                TemplateName     = "Controller",
                TemplateType     = templateCriteria.TemplateType
            };

            return(GetMvcControllerTextTemplateFileName(defaultControllerTemplateCriteria));
        }
Esempio n. 10
0
        string GetMvcViewTemplatePath(MvcTextTemplateCriteria templateCriteria)
        {
            var emptyViewTemplateCriteria = new MvcTextTemplateCriteria()
            {
                TemplateLanguage = templateCriteria.TemplateLanguage,
                TemplateName     = "Empty",
                TemplateType     = templateCriteria.TemplateType
            };
            string emptyViewTemplateFileName = GetMvcViewTextTemplateFileName(emptyViewTemplateCriteria);

            return(Path.GetDirectoryName(emptyViewTemplateFileName));
        }
Esempio n. 11
0
        List <MvcViewTextTemplate> GetViewTemplates()
        {
            var templateCriteria = new MvcTextTemplateCriteria()
            {
                TemplateLanguage = GetTemplateLanguage(),
                TemplateType     = selectedViewEngine.TemplateType
            };

            return(textTemplateRepository
                   .GetMvcViewTextTemplates(templateCriteria)
                   .OrderBy(t => t.Name)
                   .ToList());
        }
		public void GetMvcViewTextTemplateFileName_VisualBasicEmptyTemplateRequested_ReturnsFileNameToVisualBasicEmptyTextTemplate()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			
			var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.VisualBasic,
				TemplateName = "Empty",
				TemplateType = MvcTextTemplateType.Aspx
			};
			
			string fileName = repository.GetMvcViewTextTemplateFileName(templateCriteria);
			
			string expectedFileName = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\VisualBasic\CodeTemplates\AddView\AspxVisualBasic\Empty.tt";
			
			Assert.AreEqual(expectedFileName, fileName);
		}
		public void GetMvcControllerTextTemplateFileName_CSharpControllerTemplateRequested_ReturnsFileNameToCSharpControllerTextTemplate()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			
				var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.CSharp,
				TemplateName = "Controller",
				TemplateType = MvcTextTemplateType.Aspx
			};

			string fileName = repository.GetMvcControllerTextTemplateFileName(templateCriteria);
			
			string expectedFileName = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddController\Controller.tt";
			
			Assert.AreEqual(expectedFileName, fileName);
		}
        IEnumerable <FileName> GetMvcViewTemplateFileNamesInFolder(MvcTextTemplateCriteria templateCriteria)
        {
            string templatePath = GetMvcViewTemplatePath(templateCriteria);

            return(fileSystem.GetFiles(DirectoryName.Create(templatePath), "*.tt"));
        }
		public IEnumerable<MvcControllerTextTemplate> GetMvcControllerTextTemplates(MvcTextTemplateCriteria templateCriteria)
		{
			string templateFileName = GetDefaultMvcControllerTextTemplateFileName(templateCriteria);
			yield return CreateEmptyControllerTemplate(templateFileName);
			yield return CreateEmptyReadWriteControllerTemplate(templateFileName);
		}
		public string GetMvcControllerTextTemplateFileName(MvcTextTemplateCriteria templateCriteria)
		{
			var fileName = new MvcControllerTextTemplateFileName(textTemplatesRootDirectory, templateCriteria);
			return fileName.GetPath();
		}
		public IEnumerable<MvcViewTextTemplate> GetMvcViewTextTemplates(MvcTextTemplateCriteria templateCriteria)
		{
			TemplateCriteriaPassedToGetMvcViewTextTemplates = templateCriteria;
			return ViewTextTemplates;
		}
		public void GetMvcViewTextTemplates_CSharpRazorTemplatesRequestedAndTwoViewTemplatesInFolder_ReturnsTwoViewTextTemplates()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			string templateFolder = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML";
			string[] templateFileNames = new string[] {
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\B.tt",
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\A.tt"
			};
			AddTextTemplatesToFolder(templateFolder, templateFileNames);
			
			var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.CSharp,
				TemplateType = MvcTextTemplateType.Razor
			};
			
			List<MvcViewTextTemplate> templates = repository.GetMvcViewTextTemplates(templateCriteria).ToList();
			
			var expectedTemplate1 = new MvcViewTextTemplate() {
				Name = "B",
				FileName = templateFileNames[0]
			};
			var expectedTemplate2 = new MvcViewTextTemplate() {
				Name = "A",
				FileName = templateFileNames[1]
			};
			var expectedTemplates = new MvcViewTextTemplate[] {
				expectedTemplate1,
				expectedTemplate2
			};
			
			MvcViewTextTemplateCollectionAssert.AreEqual(expectedTemplates, templates);
		}
		public void GetMvcControllerTextTemplates_CSharpAspxTemplatesRequestedAndOneControllerTemplateInFolder_ReturnsTwoCSharpAspxControllerTextTemplates()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			
			var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.CSharp,
				TemplateType = MvcTextTemplateType.Aspx
			};
			
			List<MvcControllerTextTemplate> templates = repository.GetMvcControllerTextTemplates(templateCriteria).ToList();
			
			string existingTemplateFileName = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddController\Controller.tt";
			
			var expectedTemplate1 = new MvcControllerTextTemplate() {
				Name = "Empty",
				Description = "Empty controller",
				FileName = existingTemplateFileName,
				AddActionMethods = false
			};
			var expectedTemplate2 = new MvcControllerTextTemplate() {
				Name = "EmptyReadWrite",
				Description = "Controller with create, read, update and delete actions",
				FileName = existingTemplateFileName,
				AddActionMethods = true
			};
			var expectedTemplates = new MvcControllerTextTemplate[] {
				expectedTemplate1,
				expectedTemplate2
			};
			
			MvcControllerTextTemplateCollectionAssert.AreEqual(expectedTemplates, templates);
		}
Esempio n. 20
0
 public MvcControllerTextTemplateFileName(
     string textTemplatesRootFolder,
     MvcTextTemplateCriteria templateCriteria)
     : base(textTemplatesRootFolder, templateCriteria)
 {
 }
 public MvcAddViewTextTemplateFolder(MvcTextTemplateCriteria criteria)
 {
     name = GetFolderName(criteria);
 }
        string GetFolderName(MvcTextTemplateCriteria criteria)
        {
            var templateTypeFolder = new MvcTextTemplateTypeFolder(criteria);

            return("AddView\\" + templateTypeFolder.Name);
        }
		string GetFolderName(MvcTextTemplateCriteria criteria)
		{
			var templateTypeFolder = new MvcTextTemplateTypeFolder(criteria);
			return "AddView\\" + templateTypeFolder.Name;
		}
		IEnumerable<string> GetMvcViewTemplateFileNamesInFolder(MvcTextTemplateCriteria templateCriteria)
		{
			string templatePath = GetMvcViewTemplatePath(templateCriteria);
			return fileSystem.GetFiles(templatePath, "*.tt");
		}
		public IEnumerable<MvcControllerTextTemplate> GetMvcControllerTextTemplates(MvcTextTemplateCriteria templateCriteria)
		{
			TemplateCriteriaPassedToGetMvcControllerTextTemplates = templateCriteria;
			return ControllerTextTemplates;
		}
Esempio n. 26
0
        public string GetMvcControllerTextTemplateFileName(MvcTextTemplateCriteria templateCriteria)
        {
            var fileName = new MvcControllerTextTemplateFileName(textTemplatesRootDirectory, templateCriteria);

            return(fileName.GetPath());
        }
		public IEnumerable<MvcViewTextTemplate> GetMvcViewTextTemplates(MvcTextTemplateCriteria templateCriteria)
		{
			foreach (string templateFileName in GetMvcViewTemplateFileNamesInFolder(templateCriteria)) {
				yield return new MvcViewTextTemplate(templateFileName);
			}
		}
		public MvcTextTemplateTypeFolder(MvcTextTemplateCriteria criteria)
			: this(criteria.TemplateType, criteria.TemplateLanguage)
		{
		}
		IEnumerable<FileName> GetMvcViewTemplateFileNamesInFolder(MvcTextTemplateCriteria templateCriteria)
		{
			string templatePath = GetMvcViewTemplatePath(templateCriteria);
			return fileSystem.GetFiles(DirectoryName.Create(templatePath), "*.tt");
		}
		public MvcControllerTextTemplateFileName(
			string textTemplatesRootFolder,
			MvcTextTemplateCriteria templateCriteria)
			: base(textTemplatesRootFolder, templateCriteria)
		{
		}
		public void GetMvcViewTextTemplateFileName_CSharpEmptyRazorTemplateRequested_ReturnsFileNameToCSharpEmptyRazorTextTemplate()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			
			var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.CSharp,
				TemplateName = "Empty",
				TemplateType = MvcTextTemplateType.Razor
			};
			
			string fileName = repository.GetMvcViewTextTemplateFileName(templateCriteria);
			
			string expectedFileName = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Empty.tt";
			
			Assert.AreEqual(expectedFileName, fileName);
		}
Esempio n. 32
0
 public MvcTextTemplateTypeFolder(MvcTextTemplateCriteria criteria)
     : this(criteria.TemplateType, criteria.TemplateLanguage)
 {
 }
		public void GetMvcViewTextTemplates_CSharpAspxTemplatesRequestedAndOneViewTemplateInFolder_ReturnsOneViewTextTemplate()
		{
			CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc");
			string templateFolder = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp";
			string existingTemplateFileName = 
				@"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Empty.tt";
			AddTextTemplatesToFolder(templateFolder, existingTemplateFileName);
			
			var templateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = MvcTextTemplateLanguage.CSharp,
				TemplateType = MvcTextTemplateType.Aspx
			};
			
			List<MvcViewTextTemplate> templates = repository.GetMvcViewTextTemplates(templateCriteria).ToList();
			
			var expectedTemplate = new MvcViewTextTemplate() {
				Name = "Empty",
				FileName = existingTemplateFileName
			};
			var expectedTemplates = new MvcViewTextTemplate[] {
				expectedTemplate
			};
			
			MvcViewTextTemplateCollectionAssert.AreEqual(expectedTemplates, templates);
		}
		string GetMvcViewTemplatePath(MvcTextTemplateCriteria templateCriteria)
		{
			var emptyViewTemplateCriteria = new MvcTextTemplateCriteria() {
				TemplateLanguage = templateCriteria.TemplateLanguage,
				TemplateName = "Empty",
				TemplateType = templateCriteria.TemplateType
			};
			string emptyViewTemplateFileName = GetMvcViewTextTemplateFileName(emptyViewTemplateCriteria);
			return Path.GetDirectoryName(emptyViewTemplateFileName);
		}
		public MvcAddViewTextTemplateFolder(MvcTextTemplateCriteria criteria)
		{
			name = GetFolderName(criteria);
		}
Esempio n. 36
0
        IEnumerable <string> GetMvcViewTemplateFileNamesInFolder(MvcTextTemplateCriteria templateCriteria)
        {
            string templatePath = GetMvcViewTemplatePath(templateCriteria);

            return(fileSystem.GetFiles(templatePath, "*.tt"));
        }