コード例 #1
0
 // Handle cacheing of object on instantiation
 private void OnObjectCreation(Stock stock, IStockEntity stockEntity)
 {
     if (!stockCache.ContainsValue(stockEntity))
     {
         stockCache.Add(stock, stockEntity);
     }
 }
コード例 #2
0
        public Stock Convert(IStockEntity stockEntity, IStockConverter.OnObjectCreation onObjectCreation)
        {
            Stock stock = domainFactory.CreateStock(stockEntity.Id, stockEntity.ProductId, stockEntity.Amount, stockEntity.Date,
                                                    repositoryFactory.ProductsRepository.Get(stockEntity.ProductId));

            // trigger cache on instantiation to prevent looping.
            onObjectCreation(stock, stockEntity);
            return(stock);
        }