コード例 #1
0
        public string GenerateDefaultDataContextTypeName()
        {
            Project         activeProject          = base.ActiveProject;
            string          defaultModelsNamespace = MvcProjectUtil.GetDefaultModelsNamespace(ProjectExtensions.GetDefaultNamespace(activeProject));
            CodeDomProvider codeDomProvider        = ValidationUtil.GenerateCodeDomProvider(ProjectExtensions.GetCodeLanguage(activeProject));
            string          str = codeDomProvider.CreateValidIdentifier(ProjectExtensions.GetDefaultNamespace(activeProject).Replace(".", string.Empty));

            this.DataContextName = string.Concat(defaultModelsNamespace, ".", str, MvcProjectUtil.DataContextSuffix);
            return(this.DataContextName);
        }
コード例 #2
0
        protected override void CreateStaticFilesAndFolders()
        {
            base.CreateStaticFilesAndFolders();
            string viewFileExtension = MvcProjectUtil.GetViewFileExtension(ProjectExtensions.GetCodeLanguage(base.Context.ActiveProject));
            string str = Path.Combine("Views", "Shared");

            base.ActionsService.AddFolder(base.Context.ActiveProject, str);
            string str1 = Path.ChangeExtension("Error", viewFileExtension);

            base.ActionsService.AddFile(base.Context.ActiveProject, Path.Combine(str, str1), base.FilesLocatorService.GetStaticFilePath(str1, this.SearchFolders), true);
        }
コード例 #3
0
 public static string StripControllerName(string fullControllerName)
 {
     if (string.IsNullOrEmpty(fullControllerName))
     {
         return(fullControllerName);
     }
     if (!MvcProjectUtil.EndsWithController(fullControllerName))
     {
         return(fullControllerName);
     }
     return(fullControllerName.Substring(0, fullControllerName.Length - MvcProjectUtil.ControllerSuffix.Length));
 }
コード例 #4
0
        public void EnsureLayoutPageAndDependenciesCreated(string areaName, string areaRelativePath, bool isBundleConfigPresent)
        {
            string str;
            string viewFileExtension = MvcProjectUtil.GetViewFileExtension(ProjectExtensions.GetCodeLanguage(base.Context.ActiveProject));
            string str1 = Path.ChangeExtension("_ViewStart", viewFileExtension);

            str = (!string.IsNullOrEmpty(areaRelativePath) ? Path.Combine(areaRelativePath, "Views") : "Views");
            if (!File.Exists(Path.Combine(ProjectExtensions.GetFullPath(base.Context.ActiveProject), str, str1)))
            {
                string codeFileExtension = ProjectExtensions.GetCodeLanguage(base.Context.ActiveProject).CodeFileExtension;
                string textTemplatePath  = base.FilesLocatorService.GetTextTemplatePath("_ViewStart", this.SearchFolders, codeFileExtension);
                ICodeGeneratorActionsService actionsService = base.ActionsService;
                Project activeProject            = base.Context.ActiveProject;
                string  str2                     = Path.Combine(str, "_ViewStart");
                Dictionary <string, object> strs = new Dictionary <string, object>()
                {
                    { "AreaName", areaName }
                };
                actionsService.AddFileFromTemplate(activeProject, str2, textTemplatePath, strs, true);
                string str3 = Path.ChangeExtension("_Layout", viewFileExtension);
                string str4 = Path.Combine(str, "Shared");
                if (!File.Exists(Path.Combine(ProjectExtensions.GetFullPath(base.Context.ActiveProject), str4, str3)))
                {
                    textTemplatePath = base.FilesLocatorService.GetTextTemplatePath("_Layout", this.SearchFolders, codeFileExtension);
                    ICodeGeneratorActionsService codeGeneratorActionsService = base.ActionsService;
                    Project project = base.Context.ActiveProject;
                    string  str5    = Path.Combine(str4, "_Layout");
                    Dictionary <string, object> strs1 = new Dictionary <string, object>()
                    {
                        { "IsBundleConfigPresent", isBundleConfigPresent },
                        { "JQueryVersion", this.Repository.GetPackageVersion(base.Context, NuGetPackages.JQueryNuGetPackageId) },
                        { "ModernizrVersion", this.Repository.GetPackageVersion(base.Context, NuGetPackages.ModernizrNuGetPackageId) }
                    };
                    codeGeneratorActionsService.AddFileFromTemplate(project, str5, textTemplatePath, strs1, true);
                    if (!base.Context.Items.ContainsProperty("MVC_IsLayoutPageCreated"))
                    {
                        base.Context.Items.AddProperty("MVC_IsLayoutPageCreated", true);
                    }
                    textTemplatePath = base.FilesLocatorService.GetTextTemplatePath("Site", this.SearchFolders, codeFileExtension);
                    Version assemblyVersion = ProjectReferences.GetAssemblyVersion(base.Context.ActiveProject, AssemblyVersions.MvcAssemblyName);
                    ICodeGeneratorActionsService actionsService1 = base.ActionsService;
                    Project activeProject1            = base.Context.ActiveProject;
                    string  str6                      = Path.Combine("Content", "Site");
                    Dictionary <string, object> strs2 = new Dictionary <string, object>()
                    {
                        { "MvcVersion", assemblyVersion }
                    };
                    actionsService1.AddFileFromTemplate(activeProject1, str6, textTemplatePath, strs2, true);
                }
            }
        }
コード例 #5
0
        public static string GetProjectRelativePath(this ProjectItem projectItem)
        {
            Project containingProject = projectItem.ContainingProject;
            string  str      = null;
            string  fullPath = ProjectExtensions.GetFullPath(containingProject);

            fullPath = MvcProjectUtil.EnsureTrailingBackSlash(fullPath);
            string fullPath1 = ProjectExtensions.GetFullPath(projectItem);

            if (!string.IsNullOrEmpty(fullPath) && !string.IsNullOrEmpty(fullPath1))
            {
                str = CoreScaffoldingUtil.MakeRelativePath(fullPath1, fullPath);
            }
            return(str);
        }