// Returns the list of files for the specified content version.
        public static IEnumerable <string> GetFilesToList(string contentVersion)
        {
            IdentityGeneratorFiles config = GetConfigContentVersion(contentVersion);

            return(config.NamedFileConfig
                   .Where(c => c.Value.Any(f => f.ShowInListFiles))
                   .Select(c => c.Key));
        }
        static IdentityGeneratorFilesConfig()
        {
            string       configStr      = string.Empty;
            const string configFileName = "Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Identity.identitygeneratorfilesconfig.json";

            using (var configStream = typeof(IdentityGeneratorFilesConfig).Assembly.GetManifestResourceStream(configFileName))
                using (var reader = new StreamReader(configStream))
                {
                    configStr = reader.ReadToEnd();
                }

            _config = Newtonsoft.Json.JsonConvert.DeserializeObject <IdentityGeneratorFiles>(configStr);
        }
        internal static IdentityGeneratorFile[] GetFilesToGenerate(IEnumerable <string> names, IdentityGeneratorTemplateModel templateModel)
        {
            if (templateModel == null)
            {
                throw new ArgumentNullException(nameof(templateModel));
            }

            List <IdentityGeneratorFile> filesToGenerate = GetDataModelFiles(templateModel);

            if (templateModel.GenerateLayout)
            {
                IdentityGeneratorFile layout = new IdentityGeneratorFile()
                {
                    Name            = "_Layout",
                    SourcePath      = "_Layout.cshtml",
                    OutputPath      = Path.Combine(templateModel.SupportFileLocation, "_Layout.cshtml"),
                    IsTemplate      = true,
                    ShowInListFiles = false
                };
                filesToGenerate.Add(layout);
            }
            else
            {
                IdentityGeneratorFile validationScriptsPartial = new IdentityGeneratorFile()
                {
                    Name            = "_ValidationScriptsPartial",
                    SourcePath      = "Pages/_ValidationScriptsPartial.cshtml",
                    OutputPath      = "Areas/Identity/Pages/_ValidationScriptsPartial.cshtml",
                    IsTemplate      = false,
                    ShouldOverWrite = OverWriteCondition.Never
                };
                filesToGenerate.Add(validationScriptsPartial);
            }

            if (!string.IsNullOrEmpty(templateModel.Layout))
            {
                filesToGenerate.Add(ViewStart);

                // if there's a layout file, generate a _ValidationScriptsPartial.cshtml in the same place.
                IdentityGeneratorFile layoutPeerValidationScriptsPartial = new IdentityGeneratorFile()
                {
                    Name            = "_ValidationScriptsPartial",
                    SourcePath      = "Pages/_ValidationScriptsPartial.cshtml",
                    OutputPath      = Path.Combine(templateModel.SupportFileLocation, "_ValidationScriptsPartial.cshtml"),
                    IsTemplate      = false,
                    ShouldOverWrite = OverWriteCondition.Never
                };
                filesToGenerate.Add(layoutPeerValidationScriptsPartial);
            }

            string contentVersion;

            if (templateModel is IdentityGeneratorTemplateModel2 templateModel2)
            {
                contentVersion = templateModel2.ContentVersion;
            }
            else
            {
                contentVersion = IdentityGenerator.ContentVersionDefault;
            }

            IdentityGeneratorFiles config = GetConfigContentVersion(contentVersion);

            if (!templateModel.UseDefaultUI)
            {
                if (names != null && names.Any())
                {
                    foreach (var name in names)
                    {
                        filesToGenerate.AddRange(config.NamedFileConfig[name]);
                    }
                }
                else
                {
                    filesToGenerate.AddRange(config.NamedFileConfig
                                             .Where(x => !string.Equals(x.Key, "wwwroot", StringComparison.OrdinalIgnoreCase))
                                             .SelectMany(f => f.Value));
                }
            }

            if (!templateModel.HasExistingNonEmptyWwwRoot)
            {
                filesToGenerate.AddRange(config.NamedFileConfig["WwwRoot"]);
            }

            filesToGenerate.Add(IdentityHostingStartup);
            filesToGenerate.Add(ReadMe);

            return(filesToGenerate.Distinct(new IdentityGeneratorFileComparer()).ToArray());
        }