public void write_obj <T>(List <T> obj_list, int tag) where T : SprotoTypeBase { if (obj_list == null || obj_list.Count <= 0) { return; } write_func func = delegate { foreach (SprotoTypeBase v in obj_list) { this.encode_struct(v); } }; write_set(func, tag); }
public void write_obj <TK, TV>(Dictionary <TK, TV> map, int tag) where TV : SprotoTypeBase { if (map == null || map.Count <= 0) { return; } write_func func = delegate { foreach (var pair in map) { this.encode_struct(pair.Value); } }; write_set(func, tag); }
private void write_set(write_func func, int tag) { int sz_pos = this.data.Position; this.data.Seek(SprotoTypeSize.sizeof_length, SeekOrigin.Current); func(); int cur_pos = this.data.Position; int sz = (int)(cur_pos - sz_pos - SprotoTypeSize.sizeof_length); this.data.Seek(sz_pos, SeekOrigin.Begin); this.fill_size(sz); this.data.Seek(cur_pos, SeekOrigin.Begin); this.write_tag(tag, 0); }