Exemplo n.º 1
0
            public void EmitWrite(WriterEmitContext context)
            {
                var il = context.Il;

                foreach (var field in fields)
                {
                    var writer = AllWriters.GetWriter(field);

                    var manifest = GetManifestValue(field);

                    void LoadValue()
                    {
                        il.Emit(writer.RequiresAddress ? OpCodes.Ldflda : OpCodes.Ldfld, field);
                    }

                    using (context.Scope(LoadValue, manifest: manifest))
                    {
                        // if the writer does not write manifest, this will write manifest for the writer
                        if (writer is IWriteManifest == false)
                        {
                            context.WriteManifest();
                        }

                        writer.EmitWrite(context);
                    }

                    if (writer is IUpdateOffset == false)
                    {
                        context.AddToCurrentOffset();
                    }
                }
            }
Exemplo n.º 2
0
        static ushort GetManifestValue(FieldInfo field)
        {
            var order = (byte)field.GetCustomAttribute <DataMemberAttribute>().Order;
            var value = AllWriters.GetWriter(field).Manifest;

            return((ushort)(order | (value << 8)));
        }
Exemplo n.º 3
0
 static bool IsBoundedSize(FieldInfo field) => AllWriters.GetWriter(field) is IBoundedSizeWriter;
Exemplo n.º 4
0
 static bool IsVarSize(FieldInfo field) => AllWriters.GetWriter(field) is IVarSizeWriter;
Exemplo n.º 5
0
 static IBoundedSizeWriter GetBoundedSizeWriter(FieldInfo field) => (IBoundedSizeWriter)AllWriters.GetWriter(field);
Exemplo n.º 6
0
 static IVarSizeWriter GetVarSizeWriter(FieldInfo field) => (IVarSizeWriter)AllWriters.GetWriter(field);