private void _set <T>(int tag, out KeyValuePair <Type, typeFunc> field) where T : SprotoTypeBase, new() { typeFunc _func = delegate(byte[] buffer, int offset) { T obj = new T(); obj.init(buffer, offset); return(obj); }; field = new KeyValuePair <Type, typeFunc> (typeof(T), _func); }
static private void _set <T>(Dictionary <int, KeyValuePair <Type, typeFunc> > dictionary, int tag) where T : SprotoTypeBase, new() { if (dictionary.ContainsKey(tag)) { SprotoTypeSize.error("redefine tag: " + tag); } typeFunc _func = delegate(byte[] buffer, int offset) { T obj = new T(); obj.init(buffer, offset); return(obj); }; KeyValuePair <Type, typeFunc> kv = new KeyValuePair <Type, typeFunc> (typeof(T), _func); dictionary.Add(tag, kv); }