Exemplo n.º 1
0
        protected internal override void AddRuntimePackages(List <NuGetPackage> packages)
        {
            object obj = null;

            base.AddRuntimePackages(packages);
            if (base.Model.IsReferenceScriptLibrariesSelected && !AddDependencyUtil.IsBundleConfigPresent(base.Context))
            {
                string[] jQueryPackageSet = NuGetPackages.JQueryPackageSet;
                for (int i = 0; i < (int)jQueryPackageSet.Length; i++)
                {
                    string str = jQueryPackageSet[i];
                    if (!packages.Any <NuGetPackage>((NuGetPackage p) => string.Equals(p.PackageId, str, StringComparison.Ordinal)))
                    {
                        packages.Add(base.Repository.GetPackage(base.Context, str));
                    }
                }
            }
            if (base.Context.Items.ContainsProperty("MVC_IsLayoutPageCreated"))
            {
                base.Context.Items.TryGetProperty <object>("MVC_IsLayoutPageCreated", out obj);
                if ((bool)obj)
                {
                    string[] layoutPageDependencyPackageSet = NuGetPackages.LayoutPageDependencyPackageSet;
                    for (int j = 0; j < (int)layoutPageDependencyPackageSet.Length; j++)
                    {
                        string str1 = layoutPageDependencyPackageSet[j];
                        if (!packages.Any <NuGetPackage>((NuGetPackage p) => string.Equals(p.PackageId, str1, StringComparison.Ordinal)))
                        {
                            packages.Add(base.Repository.GetPackage(base.Context, str1));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void GenerateWebConfig(bool isBundleConfigPresent)
        {
            IDictionary <string, object> templateParametersForWebConfig = AddDependencyUtil.GetTemplateParametersForWebConfig(isBundleConfigPresent, base.Context);
            string codeFileExtension = ProjectExtensions.GetCodeLanguage(base.Context.ActiveProject).CodeFileExtension;
            string str = Path.Combine("Views", "web");
            string textTemplatePath = base.FilesLocatorService.GetTextTemplatePath("web", this.SearchFolders, codeFileExtension);

            base.ActionsService.AddFileFromTemplate(base.Context.ActiveProject, str, textTemplatePath, templateParametersForWebConfig, true);
        }
Exemplo n.º 3
0
 private void EnsureLayoutPageAndDependenciesCreated()
 {
     if (base.Model.IsLayoutPageSelected && string.IsNullOrEmpty(base.Model.LayoutPageFile))
     {
         bool flag = AddDependencyUtil.IsBundleConfigPresent(base.Context);
         MvcFullDependencyInstaller mvcFullDependencyInstaller = new MvcFullDependencyInstaller(base.Context, base.VisualStudioIntegration, base.Repository);
         mvcFullDependencyInstaller.EnsureLayoutPageAndDependenciesCreated(base.Model.AreaName, base.Model.AreaRelativePath, flag);
     }
 }
Exemplo n.º 4
0
        private IDictionary <string, object> AddViewTemplateParameters(ModelMetadata modelMetadata, CodeGenerationContext context)
        {
            if (modelMetadata == null)
            {
                throw new ArgumentNullException("modelMetadata");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(base.Model.ViewName))
            {
                throw new InvalidOperationException("The view name is invalid.");
            }
            IDictionary <string, object> strs = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase)
            {
                { "ModelMetadata", modelMetadata },
                { "ViewName", base.Model.ViewName },
                { "LayoutPageFile", base.Model.LayoutPageFile ?? string.Empty },
                { "IsPartialView", base.Model.IsPartialViewSelected },
                { "IsLayoutPageSelected", base.Model.IsLayoutPageSelected },
                { "ReferenceScriptLibraries", base.Model.IsReferenceScriptLibrariesSelected },
                { "IsBundleConfigPresent", AddDependencyUtil.IsBundleConfigPresent(context) },
                { "JQueryVersion", base.Repository.GetPackageVersion(base.Context, NuGetPackages.JQueryNuGetPackageId) }
            };
            Version assemblyVersion = ProjectReferences.GetAssemblyVersion(base.Context.ActiveProject, AssemblyVersions.MvcAssemblyName);

            strs.Add("MvcVersion", assemblyVersion);
            if (base.Model.ModelType != null)
            {
                CodeType codeType = base.Model.ModelType.CodeType;
                strs.Add("ViewDataTypeName", codeType.FullName);
                strs.Add("ViewDataTypeShortName", codeType.Name);
                strs.Add("ViewDataType", codeType);
            }
            else
            {
                strs.Add("ViewDataTypeName", string.Empty);
            }
            return(strs);
        }
Exemplo n.º 5
0
        protected void CreateAppStartFiles(string configFileName, string productNamespace)
        {
            string str = configFileName;
            int    num = 2;

            while (true)
            {
                Project  activeProject = this.Context.ActiveProject;
                CodeType codeType      = this.CodeTypeService.GetCodeType(activeProject, string.Concat(ProjectExtensions.GetDefaultNamespace(activeProject), ".", configFileName));
                string   str1          = string.Concat(configFileName, ".", ProjectExtensions.GetCodeLanguage(this.Context.ActiveProject).CodeFileExtension);
                string   str2          = Path.Combine(ProjectExtensions.GetFullPath(this.Context.ActiveProject), "App_Start", str1);
                if (!File.Exists(Path.Combine(ProjectExtensions.GetFullPath(this.Context.ActiveProject), "App_Start", str1)) && codeType == null)
                {
                    this.AppStartFileNames.Add(str, configFileName);
                    this.GenerateT4File(str, configFileName, "App_Start");
                    return;
                }
                if (codeType != null && !codeType.Name.StartsWith("BundleConfig", StringComparison.OrdinalIgnoreCase) && CodeTypeFilter.IsProductNamespaceImported(codeType, productNamespace))
                {
                    this.AppStartFileNames.Add(str, configFileName);
                    return;
                }
                if (codeType != null && codeType.Name.StartsWith("BundleConfig", StringComparison.OrdinalIgnoreCase) && AddDependencyUtil.IsSearchTextPresent(str2, "ScriptBundle(\"~/bundles/jquery\")"))
                {
                    break;
                }
                configFileName = string.Concat(str, num);
                num++;
            }
            this.AppStartFileNames.Add(str, configFileName);
        }