public bool Parse() { this.LogInputs(); Parser.LogAll($"Generating resources for {this.ResxFile}"); if (!this.IsPublic && !this.IsInternal) { LogAll($"Unknown Generator: {this.Generator}. Specify PublicResXFileCodeGenerator or ResXFileCodeGenerator"); return(false); } if (string.IsNullOrEmpty(this.Output)) { LogAll($"Missing Output."); return(false); } string nameSpace = ( !string.IsNullOrEmpty(this.WrapperNamespace) ? this.WrapperNamespace : ( !string.IsNullOrEmpty(this.ResxFolder) ? Parser.Format("{0}.{1}", this.NameSpace, this.ResxFolder.Replace('\\', '.')) : this.NameSpace ) ); Regex regex = new Regex(@"^\s*" + Regex.Escape(Path.ChangeExtension(this.ResxFile, null)) + @"\.[a-zA-Z\-]{2,20}\.resx\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); IEnumerable <string> satelites = this.AllItems.Split(';').Where(i => !string.IsNullOrWhiteSpace(i) && regex.IsMatch(i)).Select(i => Path.Combine(this.ProjectFolder, i.Trim())).ToArray(); string resourceName = ( !string.IsNullOrEmpty(this.ResxFolder) ? Parser.Format("{0}.{1}.{2}", this.NameSpace, this.ResxFolder.Replace('\\', '.'), this.ResxName) : Parser.Format("{0}.{1}", this.NameSpace, this.ResxName) ); ResourcesWrapper resourcesWrapper = new ResourcesWrapper() { File = Path.Combine(this.ProjectFolder, this.ResxFile), Code = Path.Combine(this.ProjectFolder, this.ResxFolder, this.Output), NameSpace = nameSpace, ClassName = this.ResxName.Replace('.', '_'), ResourceName = resourceName, IsPublic = this.IsPublic, Pseudo = this.Pseudo, EnforceParameterDeclaration = !this.OptionalParameterDeclaration, FlowDirection = this.FlowDirection, Satelites = satelites }; return(resourcesWrapper.Generate()); //return true; }
public bool Generate(string projectPath, IEnumerable <string> pseudo, bool enforceParameterDeclaration, bool flowDirection) { List <Resource> list = this.Parse(projectPath); bool success = true; foreach (Resource resource in list) { success &= new ResourcesWrapper() { File = resource.file, Code = resource.code, NameSpace = resource.nameSpace, ClassName = resource.className, ResourceName = resource.name, IsPublic = resource.isPublic, Pseudo = pseudo.Contains(resource.name, StringComparer.OrdinalIgnoreCase), EnforceParameterDeclaration = enforceParameterDeclaration, FlowDirection = flowDirection, Satelites = resource.sateliteList }.Generate(); } return(success); }