コード例 #1
0
        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("}");
        }
コード例 #2
0
ファイル: Python.cs プロジェクト: blockspacer/niveum
        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");
            }
        }