예제 #1
0
        protected override void Initialize()
        {
            this.isToggled = LocalPersistentContext <bool> .Create(PersistentContext.Get(this.Property.Path, SirenixEditorGUI.ExpandFoldoutByDefault));

            this.drawUnityObject    = typeof(UnityEngine.Object).IsAssignableFrom(this.ValueEntry.TypeOfValue);
            this.allowSceneObjects  = this.Property.GetAttribute <AssetsOnlyAttribute>() == null;
            this.bakedDrawerArray   = this.Property.GetActiveDrawerChain().BakedDrawerArray;
            this.inlinePropertyAttr = this.Property.Attributes.GetAttribute <InlinePropertyAttribute>();
        }
예제 #2
0
        public SqlUnitOfWork(IConfiguration configuration)
        {
            Configuration = configuration;

            var optionsBuilder = new DbContextOptionsBuilder <QuasarFireOperationContext>();

            optionsBuilder.UseSqlServer(configuration.GetConnectionString("MyDataBase"));
            Database = new PersistentContext(optionsBuilder.Options);
        }
예제 #3
0
        public void Dispose()
        {
            if (_disposed.HasFlag(TxState.Disposed))
            {
                return;
            }

            try
            {
                if (!Committed && !RolledBack && Flags == TransactionFlags.ReadWrite)
                {
                    Rollback();
                }

                _disposed |= TxState.Disposed;

                PersistentContext.FreePageLocator(_pageLocator);
            }
            finally
            {
                _env.TransactionCompleted(this);

                foreach (var pagerState in _pagerStates)
                {
                    pagerState.Release();
                }

                if (JournalFiles != null)
                {
                    foreach (var journalFile in JournalFiles)
                    {
                        journalFile.Release();
                    }
                }

                _root?.Dispose();
                _freeSpaceTree?.Dispose();

                _allocator.AllocationFailed -= MarkTransactionAsFailed;
                if (_disposeAllocator)
                {
                    _allocator.Dispose();
                }

                OnDispose?.Invoke(this);
            }
        }
예제 #4
0
        public void OrderSave()
        {
            var options = new DbContextOptionsBuilder <PersistentContext>()
                          .UseInMemoryDatabase(databaseName: "order_test")
                          .Options;

            // Run the test against one instance of the context
            var context         = new PersistentContext(options);
            var orderRepository = new OrderRepository(context);
            var queueService    = new QueueService();

            OrderService orderService = new OrderService(orderRepository, queueService);


            var order = new Order()
            {
                Id = 32322, Quantity = 2, Side = "buy", Symbol = "PETR4", Price = 11
            };

            queueService.AddOrderInQueue(order);
        }
예제 #5
0
        private LowLevelTransaction(LowLevelTransaction previous, long txId)
        {
            // this is meant to be used with transaction merging only
            // so it makes a lot of assumptions about the usage scenario
            // and what it can do

            Debug.Assert(previous.Flags == TransactionFlags.ReadWrite);

            var env = previous._env;

            env.Options.AssertNoCatastrophicFailure();

            FlushInProgressLockTaken = previous.FlushInProgressLockTaken;
            CurrentTransactionHolder = previous.CurrentTransactionHolder;
            TxStartTime        = DateTime.UtcNow;
            DataPager          = env.Options.DataPager;
            _env               = env;
            _journal           = env.Journal;
            _id                = txId;
            _freeSpaceHandling = previous._freeSpaceHandling;
            _allocator         = previous._allocator;

            _disposeAllocator          = previous._disposeAllocator;
            previous._disposeAllocator = false;

            PersistentContext = previous.PersistentContext;
            Flags             = TransactionFlags.ReadWrite;

            _pagerStates = new HashSet <PagerState>(ReferenceEqualityComparer <PagerState> .Default);

            JournalFiles = previous.JournalFiles;

            foreach (var journalFile in JournalFiles)
            {
                journalFile.AddRef();
            }

            var pagers = new HashSet <AbstractPager>();

            foreach (var scratchAndDataPagerState in previous._pagerStates)
            {
                // in order to avoid "dragging" pager state ref on non active scratch - we will not copy disposed scratches from previous async tx. RavenDB-6766
                if (scratchAndDataPagerState.DiscardOnTxCopy)
                {
                    continue;
                }

                // copy the "current pager" which is the last pager used, and by that do not "drag" old non used pager state refs to the next async commit (i.e. older views of data file). RavenDB-6949
                var currentPager = scratchAndDataPagerState.CurrentPager;
                if (pagers.Add(currentPager) == false)
                {
                    continue;
                }

                var state = currentPager.PagerState;
                state.AddRef();
                _pagerStates.Add(state);
            }


            EnsureNoDuplicateTransactionId(_id);

            // we can reuse those instances, not calling Reset on the pool
            // because we are going to need to scratch buffer pool
            _dirtyOverflowPages = previous._dirtyOverflowPages;
            _dirtyOverflowPages.Clear();

            _scratchPagesTable = _env.WriteTransactionPool.ScratchPagesReadyForNextTx;

            foreach (var kvp in previous._scratchPagesTable)
            {
                if (previous._dirtyPages.Contains(kvp.Key))
                {
                    _scratchPagesTable.Add(kvp.Key, kvp.Value);
                }
            }
            previous._scratchPagesTable.Clear();
            _env.WriteTransactionPool.ScratchPagesInUse          = _scratchPagesTable;
            _env.WriteTransactionPool.ScratchPagesReadyForNextTx = previous._scratchPagesTable;

            _dirtyPages = previous._dirtyPages;
            _dirtyPages.Clear();

            _freedPages          = new HashSet <long>(NumericEqualityComparer.BoxedInstanceInt64);
            _unusedScratchPages  = new List <PageFromScratchBuffer>();
            _transactionPages    = new HashSet <PageFromScratchBuffer>(PageFromScratchBufferEqualityComparer.Instance);
            _pagesToFreeOnCommit = new Stack <long>();

            _state = previous._state.Clone();

            _pageLocator = PersistentContext.AllocatePageLocator(this);
            InitializeRoots();
            InitTransactionHeader();
        }
 internal PerstSink(PersistentContext target, IMessageSink next)
 {
     this.next   = next;
     this.target = target;
 }
예제 #7
0
파일: VolanteSink.cs 프로젝트: kjk/volante
 internal VolanteSink(PersistentContext target, IMessageSink next)
 {
     this.next = next;
     this.target = target;
 }
 public PersistentContextContainer(PersistentContext persistentContext, PersistentContextOptions persistentContextOptions)
 {
     PersistentContext        = persistentContext;
     PersistentContextOptions = persistentContextOptions;
 }