Exemple #1
0
        Tuple <NeedsFreeContent, Action <IInternalObjectDBTransaction, DBObjectMetadata, AbstractBufferedReader, IList <ulong> > > CreateFreeContent(uint version)
        {
            var method = ILBuilder.Instance.NewMethod <Action <IInternalObjectDBTransaction, DBObjectMetadata,
                                                               AbstractBufferedReader, IList <ulong> > >($"FreeContent_{Name}_{version}");
            var ilGenerator      = method.Generator;
            var tableVersionInfo = _tableVersions.GetOrAdd(version, (ver, tableInfo) => tableInfo._tableInfoResolver.LoadTableVersionInfo(tableInfo._id, ver, tableInfo.Name), this);
            var needsFreeContent = NeedsFreeContent.No;
            var anyNeedsCtx      = tableVersionInfo.NeedsCtx();

            if (anyNeedsCtx)
            {
                ilGenerator.DeclareLocal(typeof(IReaderCtx));
                ilGenerator
                .Ldarg(0)
                .Ldarg(2)
                .Ldarg(3)
                .Newobj(() => new DBReaderWithFreeInfoCtx(null, null, null))
                .Stloc(0);
            }
            for (int fi = 0; fi < tableVersionInfo.FieldCount; fi++)
            {
                var             srcFieldInfo = tableVersionInfo[fi];
                Action <IILGen> readerOrCtx;
                if (srcFieldInfo.Handler.NeedsCtx())
                {
                    readerOrCtx = il => il.Ldloc(0);
                }
                else
                {
                    readerOrCtx = il => il.Ldarg(2);
                }
                Extensions.UpdateNeedsFreeContent(srcFieldInfo.Handler.FreeContent(ilGenerator, readerOrCtx), ref needsFreeContent);
            }
            ilGenerator.Ret();
            return(Tuple.Create(needsFreeContent, method.Create()));
        }