/// <summary> /// Creates a strongly typed resource class that uses the ASP.NET Resource Manager /// rather than using Resx .NET resources which basically results in duplicated /// resource sets loaded. Overwrites the generated. /// </summary> /// <param name="Namespace"></param> /// <returns></returns> public void CreateGlobalResxResourceDesignerFiles(string Namespace, CodeGenerationLanguage lang) { if (!WebPhysicalPath.EndsWith("\\")) { WebPhysicalPath += "\\"; } var ResPath = WebPhysicalPath + "app_globalresources\\"; var Files = Directory.GetFiles(ResPath, "*.resx"); foreach (var CurFile in Files) { var file = CurFile; var tokens = Path.GetFileName(file).Split('.'); // If there's more than two parts is a culture specific file // We're only interested in the invariant culture if (tokens.Length > 2) { continue; } // ResName: admin/default.aspx or default.aspx or resources (global or assembly resources) var ResName = Path.GetFileNameWithoutExtension(tokens[0]); ResName = ResName.Replace(".", "_"); CreateClassFromResXResource(file, Namespace, ResName, ResPath + ResName + ".Designer." + (lang == CodeGenerationLanguage.Vb ? "vb" : "cs")); } }
/// <summary> /// Creates a class containing strongly typed resources of all resource keys /// in all global resource ResX files. A single class file with multiple classes /// is created. /// The extension of the output file determines whether VB or CS is generated /// </summary> /// <param name="Namespace"></param> /// <param name="FileName">Output file name for the generated class. .cs and .vb generate appropriate languages</param> /// <returns>Generated class as a string</returns> public string CreateClassFromFromAllGlobalResXResources(string Namespace, string FileName) { if (!WebPhysicalPath.EndsWith("\\")) { WebPhysicalPath += "\\"; } var IsVb = IsFileVb(FileName); var ResPath = WebPhysicalPath + "app_globalresources\\"; var Files = Directory.GetFiles(ResPath, "*.resx"); var sbClasses = new StringBuilder(); foreach (var CurFile in Files) { var tokens = Path.GetFileName(CurFile).Split('.'); // If there's more than two parts is a culture specific file // We're only interested in the invariant culture if (tokens.Length > 2) { continue; } // ResName: admin/default.aspx or default.aspx or resources (global or assembly resources) var ResName = Path.GetFileNameWithoutExtension(tokens[0]); ResName = ResName.Replace(".", "_"); var Class = CreateClassFromResXResource(CurFile, Namespace, ResName, null); sbClasses.Append(Class); } var Output = CreateNameSpaceWrapper(Namespace, IsVb, sbClasses.ToString()); File.WriteAllText(FileName, Output); return(Output); }