Ejemplo n.º 1
0
        /// <summary>
        /// Put binary types to Grid.
        /// </summary>
        /// <param name="types">Binary types.</param>
        public void PutBinaryTypes(ICollection <BinaryType> types)
        {
            DoOutOp((int)Op.PutMeta, w =>
            {
                w.WriteInt(types.Count);

                foreach (var meta in types)
                {
                    w.WriteInt(meta.TypeId);
                    w.WriteString(meta.TypeName);
                    w.WriteString(meta.AffinityKeyFieldName);

                    var fields = meta.GetFieldsMap();

                    w.WriteInt(fields.Count);

                    foreach (var field in fields)
                    {
                        w.WriteString(field.Key);
                        w.WriteInt(field.Value.TypeId);
                        w.WriteInt(field.Value.FieldId);
                    }

                    w.WriteBoolean(meta.IsEnum);

                    // Send schemas
                    var desc = meta.Descriptor;
                    Debug.Assert(desc != null);

                    var count    = 0;
                    var countPos = w.Stream.Position;
                    w.WriteInt(0); // Reserve for count

                    foreach (var schema in desc.Schema.GetAll())
                    {
                        w.WriteInt(schema.Key);

                        var ids = schema.Value;
                        w.WriteInt(ids.Length);

                        foreach (var id in ids)
                        {
                            w.WriteInt(id);
                        }

                        count++;
                    }

                    w.Stream.WriteInt(countPos, count);
                }
            });

            Marshaller.OnBinaryTypesSent(types);
        }