private string GetKeySignature(string key, ResxValue value) { return(string.Format("{0}({1}): string", char.ToLower(key[0]) + key.Substring(1), string.Join(", ", Enumerable.Range(0, value.GetNumOfParameters()).Select(x => string.Format("param{0}: string", x))) )); }
private void WriteImplementation(IIdentWriter w, int i, ResxResult mainResx, ResxResult localizedResx) { w.WL(i, "class {0}Impl {{", mainResx.Name); foreach (var mainItem in mainResx.Entries.OrderBy(x => x.Key)) { ResxValue contentItem = null; if (!localizedResx.Entries.TryGetValue(mainItem.Key, out contentItem)) { contentItem = mainItem.Value; } WriteResourceFunction(w, i + 1, mainItem.Key, mainItem.Value, contentItem); } w.WL(i, "}"); }
private void WriteResourceFunction(IIdentWriter w, int i, string key, ResxValue structure, ResxValue content) { w.WL(i, "public {0} {{", GetKeySignature(key, structure)); var contentSegments = content.Segments.Select(seg => { if (seg.Type == SegmentType.Parameter) { return(string.Format("param{0}", ((ParameterSegment)seg).ParameterNumber)); } else { return(string.Format("\"{0}\"", ((StringSegment)seg).Value.Replace("\"", "\\\""))); } }); w.WL(i + 1, "return {0};", string.Join(" + ", contentSegments)); w.WL(i, "}"); }