示例#1
0
        public string ToProto()
        {
            StrGen.Builder _ = StrGen.GetBuilder();
            _ = _["message D"][Type]['{']['\n'];
            Entries.ForEachPairs((index, entry) => {
                string repeated = "";
                string annotate = "";
                if (entry.species == Entry.Species.List)
                {
                    repeated = "    repeated ";
                    Def def  = Get(entry.type);
                    if (def == null)
                    {
                        throw new EntityDefExpection(string.Format("The declared type {0} not exist. ", entry.type));
                    }
                    Entry sub_entry = def.GetEntry(entry.indexing);
                    if (sub_entry == null)
                    {
                        throw new EntityDefExpection(string.Format("The declared indexing {0} of list {1}.{2} not met. ", entry.indexing, Type, entry.name));
                    }
                    annotate = entry.species == Entry.Species.List ? StrGen.New["    // This list is indexed by it's col "][entry.indexing][" ("][entry.type]['.'][sub_entry.name][")"].End : "";
                }
                string typeString = entry.type.TryConvertToEnum(VType.None).ToProtoTypeString() ?? "D" + entry.type;

                _ = _[repeated][typeString][" "][entry.name][" = "][index][';'][annotate]['\n'];
            });
            _ = _['}']['\n'];
            return(_.End);
        }
示例#2
0
        public string Serialize()
        {
            StrGen.Builder builder = StrGen.GetBuilder();

            int lastRow = 0;

            DoCell((row, col, cellValue) => {
                if (row != lastRow)
                {
                    builder.Append("\n"); lastRow = row;
                }
                if (col != 0)
                {
                    builder.Append(",");
                }
                AppendString(builder, cellValue);
            });
            return(builder.GetStringAndRelease());
        }