示例#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();
                    }
                }
            }
示例#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)));
        }
示例#3
0
 static bool IsBoundedSize(FieldInfo field) => AllWriters.GetWriter(field) is IBoundedSizeWriter;
示例#4
0
 static bool IsVarSize(FieldInfo field) => AllWriters.GetWriter(field) is IVarSizeWriter;
示例#5
0
 static IBoundedSizeWriter GetBoundedSizeWriter(FieldInfo field) => (IBoundedSizeWriter)AllWriters.GetWriter(field);
示例#6
0
 static IVarSizeWriter GetVarSizeWriter(FieldInfo field) => (IVarSizeWriter)AllWriters.GetWriter(field);