/// <summary> /// Put binary types to Grid. /// </summary> /// <param name="types">Binary types.</param> internal void PutBinaryTypes(IDictionary <int, IBinaryType> types) { DoOutOp(OpMeta, stream => { BinaryWriter metaWriter = _marsh.StartMarshal(stream); metaWriter.WriteInt(types.Count); foreach (var meta in types.Values) { BinaryType meta0 = (BinaryType)meta; metaWriter.WriteInt(meta0.TypeId); metaWriter.WriteString(meta0.TypeName); metaWriter.WriteString(meta0.AffinityKeyFieldName); IDictionary <string, int> fields = meta0.FieldsMap(); metaWriter.WriteInt(fields.Count); foreach (var field in fields) { metaWriter.WriteString(field.Key); metaWriter.WriteInt(field.Value); } } _marsh.FinishMarshal(metaWriter); }); _marsh.OnBinaryTypesSent(types); }
/// <summary> /// Callback invoked when metadata has been sent to the server and acknowledged by it. /// </summary> /// <param name="newMetas">Binary types.</param> public void OnBinaryTypesSent(IDictionary <int, IBinaryType> newMetas) { foreach (KeyValuePair <int, IBinaryType> metaEntry in newMetas) { BinaryType meta = (BinaryType)metaEntry.Value; IDictionary <int, Tuple <string, int> > mergeInfo = new Dictionary <int, Tuple <string, int> >(meta.FieldsMap().Count); foreach (KeyValuePair <string, int> fieldMeta in meta.FieldsMap()) { int fieldId = BinaryUtils.FieldId(metaEntry.Key, fieldMeta.Key, null, null); mergeInfo[fieldId] = new Tuple <string, int>(fieldMeta.Key, fieldMeta.Value); } _metas[metaEntry.Key].Merge(mergeInfo); } }