예제 #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);