示例#1
0
文件: DBIndirect.cs 项目: saryn/BTDB
        public static void SaveImpl(IWriterCtx writerCtx, object obj)
        {
            var ind = obj as DBIndirect <T>;

            if (ind != null)
            {
                if (ind._transaction != null)
                {
                    if (((IDBWriterCtx)writerCtx).GetTransaction() != ind._transaction)
                    {
                        throw new BTDBException("Transaction does not match when saving nonmaterialized IIndirect");
                    }
                    writerCtx.Writer().WriteVInt64((long)ind._oid);
                    return;
                }
            }
            var ind2 = obj as IIndirect <T>;

            if (ind2 != null)
            {
                writerCtx.WriteNativeObjectPreventInline(ind2.Value);
                return;
            }
            writerCtx.WriteNativeObjectPreventInline(obj);
        }
示例#2
0
文件: DBIndirect.cs 项目: yardee/BTDB
        public static void SaveImpl(ref SpanWriter writer, IWriterCtx writerCtx, object obj)
        {
            if (obj is DBIndirect <T> ind)
            {
                if (ind._transaction != null)
                {
                    if (((IDBWriterCtx)writerCtx).GetTransaction() != ind._transaction)
                    {
                        throw new BTDBException("Transaction does not match when saving nonmaterialized IIndirect");
                    }
                    writer.WriteVInt64((long)ind._oid);
                    return;
                }
            }

            if (obj is IIndirect <T> ind2)
            {
                writerCtx.WriteNativeObjectPreventInline(ref writer, ind2.Value);
                return;
            }
            writerCtx.WriteNativeObjectPreventInline(ref writer, obj);
        }