public IEnumerable <String> Record(RecordDef r) { var Name = GetEscapedIdentifier(r.DefinitionName()) + GetGenericParameters(r.GenericParameters); foreach (var _Line in Combine(Begin(), GetXmlComment(r.Description))) { yield return(_Line); } yield return("[Record]"); foreach (var _Line in Combine(Combine(Begin(), "public sealed class "), Name)) { yield return(_Line); } yield return("{"); foreach (var f in r.Fields) { foreach (var _Line in Combine(Begin(), GetXmlComment(f.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public "), GetTypeString(f.Type, r.NamespaceName())), " "), GetEscapedIdentifier(f.Name)), ";")) { yield return(_Line == "" ? "" : " " + _Line); } } yield return("}"); }
public IEnumerable <String> Record(RecordDef r) { var Name = GetEscapedIdentifier(r.DefinitionName()) + GetGenericParameters(r.GenericParameters); yield return("#Record"); foreach (var _Line in Combine(Combine(Combine(Begin(), "class "), Name), "(NamedTuple):")) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), " "), GetXmlComment(r.Description))) { yield return(_Line); } yield return(""); foreach (var f in r.Fields) { foreach (var _Line in Combine(Begin(), GetXmlComment(f.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), GetEscapedIdentifier(f.Name)), ": "), GetTypeString(f.Type, r.NamespaceName()))) { yield return(_Line == "" ? "" : " " + _Line); } } if (r.Fields.Count == 0) { yield return(" " + "pass"); } }