Example #1
0
        /// <summary>
        /// Initializes a new instance of the Repository class.
        /// </summary>
        /// <param name="itemCache">The item cache we're using.</param>
        public Repository(IItemCache itemCache)
        {
            this.itemCache = itemCache;

            this.entries = new Dictionary<BuildObject, RepositoryEntry>();
            this.alreadyAddedVerbs = new HashSet<IVerb>();
        }
Example #2
0
        internal Basket(IItemCache itemCache, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(itemCache, "ItemCache");
            Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Basket, "itemCache");
            Mandate.ParameterNotNull(customer, "customer");

            _customer = customer;
            _itemCache = itemCache;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomerItemCacheBase"/> class.
        /// </summary>
        /// <param name="itemCache">
        /// The item cache.
        /// </param>
        /// <param name="customer">
        /// The customer.
        /// </param>
        protected CustomerItemCacheBase(IItemCache itemCache, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(itemCache, "ItemCache");
            Mandate.ParameterNotNull(customer, "customer");
            _customer = customer;
            _itemCache = itemCache;
            EnableDataModifiers = true;

            this.Initialize();
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SalePreparationBase"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="itemCache">
        /// The item cache.
        /// </param>
        /// <param name="customer">
        /// The customer.
        /// </param>
        internal SalePreparationBase(IMerchelloContext merchelloContext, IItemCache itemCache, ICustomerBase customer)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(itemCache, "ItemCache");
            Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Checkout, "itemCache");
            Mandate.ParameterNotNull(customer, "customer");

            _merchelloContext = merchelloContext;
            _customer = customer;
            _itemCache = itemCache;
            ApplyTaxesToInvoice = true;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckoutContext"/> class.
        /// </summary>
        /// <param name="customer">
        /// The <see cref="ICustomerBase"/> associated with this checkout.
        /// </param>
        /// <param name="itemCache">
        /// The temporary <see cref="IItemCache"/> of the basket <see cref="IItemCache"/> to be used in the
        /// checkout process.
        /// </param>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        /// <param name="settings">
        /// The version change settings.
        /// </param>
        public CheckoutContext(ICustomerBase customer, IItemCache itemCache, IMerchelloContext merchelloContext, ICheckoutContextSettings settings)
        {
            Mandate.ParameterNotNull(customer, "customer");
            Mandate.ParameterNotNull(itemCache, "itemCache");
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(settings, "settings");

            this.MerchelloContext = merchelloContext;
            this.ItemCache = itemCache;
            this.Customer = customer;
            this.Cache = merchelloContext.Cache.RuntimeCache;
            this.ApplyTaxesToInvoice = true;
            this.Settings = settings;
            this.RaiseCustomerEvents = false;
        }
        /// <summary>
        /// Initializes a new instance of the CloudExecutionEngine class.
        /// </summary>
        public CloudExecutionEngine()
        {
            // Establish various infrastructure.
            // TODO: Clean this up.
            this.virtualIronRoot = Directory.GetCurrentDirectory();
            string localCacheDirectory = Path.Combine(this.virtualIronRoot, "nucache");
            this.cloudCache = new ItemCacheCloud();
            this.multiplexedItemCache = new ItemCacheMultiplexer(
                    new ItemCacheLocal(localCacheDirectory),
                    this.cloudCache,
                    null);

            Console.WriteLine("Accessing execution queue.");
            this.mainQueue = new CloudExecutionQueue();
        }
Example #7
0
        /// <summary>
        /// Deletes the given items from the given caches and containers.
        /// </summary>
        /// <param name="queriedCaches">Caches to look in.</param>
        /// <param name="queriedContainers">Containers to look in.</param>
        /// <param name="queriedItems">Items to delete.</param>
        private static void DeleteItems(
            IItemCache[] queriedCaches,
            ItemCacheContainer[] queriedContainers,
            string queriedItems)
        {
            if (queriedItems == "*")
            {
                if (!DeleteItemsConfirmation())
                {
                    return;
                }
            }

            foreach (IItemCache cache in queriedCaches)
            {
                foreach (ItemCacheContainer container in queriedContainers)
                {
                    if (queriedItems == "*")
                    {
                        HashSet<string> items = cache.GetItemsInContainer(container);
                        foreach (string item in items)
                        {
                            cache.DeleteItem(container, item);
                        }
                    }
                    else
                    {
                        cache.DeleteItem(container, queriedItems);
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Provides a status report of the number of items in the specified
        /// cache containers, and optionally a list of those items.
        /// </summary>
        /// <param name="queriedCaches">Caches to examine.</param>
        /// <param name="queriedContainers">Containers in those caches to examine.</param>
        /// <param name="listContents">Whether to list the cache contents.</param>
        private static void CacheStatus(
            IItemCache[] queriedCaches,
            ItemCacheContainer[] queriedContainers,
            bool listContents)
        {
            string lineTerminator = ".";
            if (listContents)
            {
                lineTerminator = ":";
            }

            foreach (IItemCache cache in queriedCaches)
            {
                foreach (ItemCacheContainer container in queriedContainers)
                {
                    HashSet<string> items = cache.GetItemsInContainer(container);
                    Console.WriteLine("{0} cache {1} container holds {2} items{3}", cache.Name, container.ToString(), items.Count, lineTerminator);
                    if (listContents)
                    {
                        foreach (string item in items)
                        {
                            ////Console.WriteLine("Item: {0}, Date:{1}", item, cache.GetItemLastModifiedTime(container, item));
                            Console.WriteLine(item);
                        }

                        Console.WriteLine();
                    }
                }

                Console.WriteLine();
            }
        }
Example #9
0
        /// <summary>
        /// Compares the contents of two caches.
        /// </summary>
        /// <param name="queriedCaches">Caches to compare.</param>
        /// <param name="queriedContainers">Containers in those caches to compare.</param>
        private static void CompareCacheContainers(
            IItemCache[] queriedCaches,
            ItemCacheContainer[] queriedContainers)
        {
            foreach (ItemCacheContainer container in queriedContainers)
            {
                IItemCache cacheA = queriedCaches[0];
                IItemCache cacheB = queriedCaches[1];

                HashSet<string> cacheAItems = cacheA.GetItemsInContainer(container);
                HashSet<string> cacheBItems = cacheB.GetItemsInContainer(container);

                Console.WriteLine("There are {0} items in the {1} cache {2} container.", cacheAItems.Count, cacheA.Name, container.ToString());
                Console.WriteLine("There are {0} items in the {1} cache {2} container.", cacheBItems.Count, cacheB.Name, container.ToString());

                HashSet<string> syncedItems = new HashSet<string>(cacheAItems);
                syncedItems.IntersectWith(cacheBItems);
                Console.WriteLine("There are {0} items present in both cache's {1} container.", syncedItems.Count, container);
                Console.WriteLine();
            }
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckoutContext"/> class.
 /// </summary>
 /// <param name="customer">
 /// The customer.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 public CheckoutContext(ICustomerBase customer, IItemCache itemCache)
     : this(customer, itemCache, new CheckoutContextSettings())
 {
 }
Example #11
0
 //// used for testing
 /// <summary>
 /// Gets the wish list.
 /// </summary>
 /// <param name="customer">
 /// The customer.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <returns>
 /// The <see cref="IWishList"/>.
 /// </returns>
 internal static IWishList GetWishList(ICustomerBase customer, IItemCache itemCache)
 {
     return new WishList(itemCache, customer);
 }
Example #12
0
        /// <summary>
        /// Deletes a single <see cref="IItemCache"/> object
        /// </summary>
        /// <param name="itemCache">The <see cref="IItemCache"/> to delete</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IItemCache itemCache, bool raiseEvents = true)
        {
            if (raiseEvents) Deleting.RaiseEvent(new DeleteEventArgs<IItemCache>(itemCache), this);

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateItemCacheRepository(uow))
                {
                    repository.Delete(itemCache);
                    uow.Commit();
                }
            }
            if (raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<IItemCache>(itemCache), this);
        }
Example #13
0
        /// <summary>
        /// The validate.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Validate()
        {
            if (Validating.IsRaisedEventCancelled(new ValidationEventArgs<CustomerItemCacheBase>(this), this))
            {
                return true;
            }

            _validator.Value.EnableDataModifiers = this.EnableDataModifiers;
            var attempt = _validator.Value.Validate(this);
            Validated.RaiseEvent(new ValidationEventArgs<ValidationResult<CustomerItemCacheBase>>(attempt.Result), this);
            if (attempt.Success)
            {
                _itemCache = attempt.Result.Validated.ItemCache;
            }
            else
            {
                LogHelper.Debug<CustomerItemCacheBase>(attempt.Exception.Message);
                throw attempt.Exception;
            }

            return attempt.Success;
        }
Example #14
0
        /// <summary>
        /// Retrieves the requested result from the given cache.
        /// </summary>
        /// <param name="cache">Cache to query.</param>
        /// <param name="container">Container to query.</param>
        /// <param name="itemHash">Result to get.</param>
        /// <returns>The requested ResultSummaryRecord, or null if not found.</returns>
        private static ResultSummaryRecord FetchRecord(IItemCache cache, ItemCacheContainer container, string itemHash)
        {
            byte[] result = cache.FetchItem(container, itemHash);

            if (result != null)
            {
                MemoryStream resultStream = new MemoryStream(result);
                try
                {
                    using (StreamReader inReader = new StreamReader(resultStream))
                    {
                        string xmlSummary = inReader.ReadToEnd();
                        ResultSummaryRecord record = ResultSummaryRecord.FromXml(xmlSummary);
                        if (record == null)
                        {
                            Console.WriteLine("FromXml failed for {0}", itemHash);
                        }

                        return record;
                    }
                }
                catch (System.Xml.XmlException ex)
                {
                    Console.WriteLine("Malformed xml in {0}: {1}", itemHash, ex.ToString());
                    return null;
                }
                finally
                {
                    resultStream.Dispose();
                }
            }
            else
            {
                Console.WriteLine("FetchItem failed for {0}", itemHash);
                return null;
            }
        }
Example #15
0
 public SalePreparationMock(IMerchelloContext merchelloContext, IItemCache itemCache, ICustomerBase customer)
     : base(merchelloContext, itemCache, customer)
 {
 }
Example #16
0
        /// <summary>
        /// Deletes the items from the given caches and containers
        /// that have an earlier last modified time than the given one.
        /// </summary>
        /// <param name="queriedCaches">Caches to look in.</param>
        /// <param name="queriedContainers">Containers to look in.</param>
        /// <param name="queriedDate">Date to compare against.</param>
        private static void DeleteItems(
            IItemCache[] queriedCaches,
            ItemCacheContainer[] queriedContainers,
            DateTimeOffset queriedDate)
        {
            if (!DeleteItemsConfirmation())
            {
                return;
            }

            foreach (IItemCache cache in queriedCaches)
            {
                foreach (ItemCacheContainer container in queriedContainers)
                {
                    HashSet<string> items = cache.GetItemsInContainer(container);
                    foreach (string item in items)
                    {
                        DateTimeOffset? lastModified = cache.GetItemLastModifiedTime(container, item);
                        if (lastModified.HasValue && (lastModified.Value.CompareTo(queriedDate) < 0))
                        {
                            cache.DeleteItem(container, item);
                        }
                    }
                }
            }
        }
Example #17
0
        /// <summary>
        /// Dumps the given item from the given cache and container.
        /// </summary>
        /// <param name="cache">Cache to look in.</param>
        /// <param name="container">Container to look in.</param>
        /// <param name="item">Item to dump.</param>
        private static void DumpItem(IItemCache cache, ItemCacheContainer container, string item)
        {
#if true
            byte[] content = cache.FetchItem(container, item);
            if (content != null)
            {
                BinaryWriter writer = new BinaryWriter(Console.OpenStandardOutput());
                writer.Write(content);
                writer.Close();
            }
#endif
#if false
            ResultSummaryRecord record = FetchRecord(cache, container, item);
            if (record != null)
            {
                Console.WriteLine();
                Console.WriteLine("IsVerificationTimeout = {0}", record.IsVerificationTimeout);
                Console.WriteLine("IsFailure = {0}", record.IsFailure);
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("FetchRecord failed for {0}", item);
            }
#endif
        }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckoutContext"/> class.
 /// </summary>
 /// <param name="customer">
 /// The customer.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public CheckoutContext(ICustomerBase customer, IItemCache itemCache, ICheckoutContextSettings settings)
     : this(customer, itemCache, Core.MerchelloContext.Current, settings)
 {
 }
Example #19
0
        /// <summary>
        /// Saves a single <see cref="IItemCache"/> object
        /// </summary>
        /// <param name="itemCache">The <see cref="IItemCache"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IItemCache itemCache, bool raiseEvents = true)
        {
            if (raiseEvents) Saving.RaiseEvent(new SaveEventArgs<IItemCache>(itemCache), this);

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateItemCacheRepository(uow))
                {
                    repository.AddOrUpdate(itemCache);
                    uow.Commit();
                }

                if (raiseEvents) Saved.RaiseEvent(new SaveEventArgs<IItemCache>(itemCache), this);
            }
        }
Example #20
0
        public void Init()
        {
            _customer = new AnonymousCustomer() { Key = Guid.NewGuid() };
            _itemCache = new ItemCache(_customer.Key, ItemCacheType.Basket) {Key = Guid.NewGuid()};

            _product = MockProductDataMaker.MockProductComplete(Guid.NewGuid());
        }
Example #21
0
 /// <summary>
 /// Instantiates the backoffice
 /// </summary>
 /// <param name="customer">
 /// The customer.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <returns>
 /// The <see cref="IBackoffice"/>.
 /// </returns>
 internal static IBackoffice GetBackoffice(ICustomerBase customer, IItemCache itemCache)
 {
     return new Backoffice(itemCache, customer);
 }
Example #22
0
        public virtual void Init()
        {
            Customer = PreTestDataWorker.MakeExistingAnonymousCustomer();
            Basket = Web.Workflow.Basket.GetBasket(MerchelloContext, Customer);

            var odd = true;
            for (var i = 0; i < ProductCount; i++)
            {

                var product = PreTestDataWorker.MakeExistingProduct(true, WeightPerProduct, PricePerProduct);
                product.AddToCatalogInventory(PreTestDataWorker.WarehouseCatalog);
                product.CatalogInventories.First().Count = 10;
                product.TrackInventory = true;
                PreTestDataWorker.ProductService.Save(product);
                Basket.AddItem(product, 2);

                odd = !odd;
            }

            BillingAddress = new Address()
            {
                Name = "Out there",
                Address1 = "some street",
                Locality = "some city",
                Region = "ST",
                PostalCode = "98225",
                CountryCode = "US"
            };

            var origin = new Address()
            {
                Name = "Somewhere",
                Address1 = "origin street",
                Locality = "origin city",
                Region = "ST",
                PostalCode = "98225",
                CountryCode = "US"
            };

            PreTestDataWorker.DeleteAllItemCaches();
            PreTestDataWorker.DeleteAllInvoices();

            Customer.ExtendedData.AddAddress(BillingAddress, AddressType.Billing);
            ItemCache = new Core.Models.ItemCache(Customer.EntityKey, ItemCacheType.Checkout);

            PreTestDataWorker.ItemCacheService.Save(ItemCache);

            foreach (var item in Basket.Items)
            {
                ItemCache.AddItem(item.AsLineItemOf<ItemCacheLineItem>());
            }

            // setup the checkout
            SalePreparationMock = new SalePreparationMock(MerchelloContext, ItemCache, Customer);

            // add the shipment rate quote
            var shipment = Basket.PackageBasket(MerchelloContext, BillingAddress).First();
            var shipRateQuote = shipment.ShipmentRateQuotes(MerchelloContext).FirstOrDefault();

            //_checkoutMock.ItemCache.Items.Add(shipRateQuote.AsLineItemOf<InvoiceLineItem>());
            SalePreparationMock.SaveShipmentRateQuote(shipRateQuote);
        }
Example #23
0
 /// <summary>
 /// Dumps the given items from the given caches and containers.
 /// </summary>
 /// <param name="queriedCaches">Caches to look in.</param>
 /// <param name="queriedContainers">Containers to look in.</param>
 /// <param name="queriedItems">Items to dump.</param>
 private static void DumpItems(
     IItemCache[] queriedCaches,
     ItemCacheContainer[] queriedContainers,
     string queriedItems)
 {
     foreach (IItemCache cache in queriedCaches)
     {
         foreach (ItemCacheContainer container in queriedContainers)
         {
             if (queriedItems == "*")
             {
                 HashSet<string> items = cache.GetItemsInContainer(container);
                 foreach (string item in items)
                 {
                     DumpItem(cache, container, item);
                 }
             }
             else
             {
                 DumpItem(cache, container, queriedItems);
             }
         }
     }
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Basket"/> class.
 /// </summary>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <param name="customer">
 /// The customer.
 /// </param>
 internal Basket(IItemCache itemCache, ICustomerBase customer)
     : base(itemCache, customer)
 {
     Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Basket, "itemCache");
 }
Example #25
0
        /// <summary>
        /// Checks the given cache(s) Results and FailedResults for goodness.
        /// </summary>
        /// <param name="queriedCaches">Caches to check.</param>
        /// <param name="cleanup">Whether to cleanup after bad cache entries.</param>
        private static void CheckResults(
            IItemCache[] queriedCaches,
            bool cleanup)
        {
            // We can do this for Local, Cloud, or both.
            foreach (IItemCache cache in queriedCaches)
            {
                // We have one Objects container for objects referenced by
                // results in both the Results and FailedResults containers.
                HashSet<string> objects = cache.GetItemsInContainer(ItemCacheContainer.Objects);

                // Likewise, we have only one Sources container.
                // REVIEW: Should a "source" ever show up as a verb result?
                HashSet<string> sources = cache.GetItemsInContainer(ItemCacheContainer.Sources);

                // We initialize the orphanedObjects set to all objects and
                // then remove objects from the set when we find them listed
                // in a result (stored in either Results or FailedResults).
                HashSet<string> orphanedObjects = cache.GetItemsInContainer(ItemCacheContainer.Objects);

                // We check both successful and failed results.
                foreach (ItemCacheContainer resultsContainer in new ItemCacheContainer[] { ItemCacheContainer.Results, ItemCacheContainer.FailedResults })
                {
                    HashSet<string> parseErrors = new HashSet<string>();

                    // Misfiled results (i.e. failures in Results container or
                    // non-failures in FailedResults container).
                    HashSet<string> misfiledResults = new HashSet<string>();

                    // Results that are missing one or more ouput objects.
                    HashSet<string> resultsMissingOutputs = new HashSet<string>();

                    HashSet<string> missingOutputHashes = new HashSet<string>();
                    HashSet<string> missingOutputPaths = new HashSet<string>();
                    int timeouts = 0;
                    int failures = 0;
                    int missing = 0;

                    HashSet<string> results = cache.GetItemsInContainer(resultsContainer);
                    foreach (string result in results)
                    {
                        ResultSummaryRecord record = FetchRecord(cache, resultsContainer, result);
                        if (record == null)
                        {
                            Console.WriteLine("Parse error in {0}.", result);
                            parseErrors.Add(result);
                        }
                        else
                        {
                            if (record.IsFailure)
                            {
                                if (resultsContainer == ItemCacheContainer.Results)
                                {
                                    // We shouldn't have any failures in Results!
                                    misfiledResults.Add(result);
                                }

                                if (record.IsVerificationTimeout)
                                {
                                    ////Console.WriteLine("Timeout in {0}.", result);
                                    timeouts++;
                                }
                                else
                                {
                                    ////Console.WriteLine("Failure in {0}.", result);
                                    failures++;
                                }
                            }
                            else if (resultsContainer == ItemCacheContainer.FailedResults)
                            {
                                // We should only have failures in FailedResults!
                                misfiledResults.Add(result);
                            }

                            // Verify each output is in the cache.
                            bool hasMissingOuputs = false;
                            foreach (BuildObjectValuePointer output in record.Outputs)
                            {
                                if (objects.Contains(output.ObjectHash))
                                {
                                    // Output present in object cache.
                                    // Remove it from orphaned objects list.
                                    orphanedObjects.Remove(output.ObjectHash);
                                }
                                else if (sources.Contains(output.ObjectHash))
                                {
                                    // Output present in sources cache.
                                    Console.WriteLine("Has 'source' file listed as an output: {0}!", result);
                                }
                                else
                                {
                                    // Output missing from both object and sources caches.
                                    hasMissingOuputs = true;
                                    missingOutputHashes.Add(output.ObjectHash);
                                    missingOutputPaths.Add(output.RelativePath);
                                    missing++;
                                    Console.WriteLine("Missing Output Listed in {0}, Object {1} ({2}).", result, output.ObjectHash, output.RelativePath);
                                }
                            }

                            if (hasMissingOuputs)
                            {
                                resultsMissingOutputs.Add(result);
                            }
                        }
                    }

                    Console.WriteLine();
                    Console.WriteLine("Checked {0} results in {1} cache {2} container:", results.Count, cache.Name, resultsContainer.ToString());
                    Console.WriteLine("Corrupted (parsing errors or otherwise unreadable): {0}", parseErrors.Count);
                    Console.WriteLine("Filed in wrong container: {0}", misfiledResults.Count);
                    Console.WriteLine("Timeouts: {0}, Other failures: {1}, Total failures: {2}", timeouts, failures, timeouts + failures);
                    Console.WriteLine("Missing at least one output object: {0}", resultsMissingOutputs.Count);
                    Console.WriteLine("Total missing output objects: {0}, Unique contents: {1}, Unique paths: {2}", missing, missingOutputHashes.Count, missingOutputPaths.Count);
                    Console.WriteLine();

                    if (cleanup)
                    {
                        if (misfiledResults.Count != 0)
                        {
                            Console.Write("Deleting misfiled results...");
                            foreach (string misfiledResult in misfiledResults)
                            {
                                cache.DeleteItem(resultsContainer, misfiledResult);
                            }

                            Console.WriteLine("Done.");
                        }

                        if (resultsMissingOutputs.Count != 0)
                        {
                            Console.Write("Deleting results with missing outputs...");
                            foreach (string resultMissingOutputs in resultsMissingOutputs)
                            {
                                cache.DeleteItem(resultsContainer, resultMissingOutputs);
                            }

                            Console.WriteLine("Done.");
                        }

                        Console.WriteLine();
                    }
                }

                // REVIEW: in at least one instance, we cache an intermediate
                // object that isn't referenced by a result.  That instance is
                // DafnyIncludes.ExpandDafny(), which is called from
                // DafnyCompileOneVerb.  This is to allow cloud execution of the
                // process invoke part of the verb's execution (with the dafny
                // expansion happening in the verb's getWorker() method).  Since
                // ExpandDafny() is a work-around for a Dafny issue, it's not
                // clear whether we should further accommodate this in the build
                // system (i.e. by making ExpandDafny its own verb) or not.
                // At any rate, having orphaned objects is not necessarily bad.
                Console.WriteLine("Orphaned objects not listed in any result: {0}", orphanedObjects.Count);

                if (cleanup)
                {
                    Console.WriteLine();

                    if (orphanedObjects.Count != 0)
                    {
                        Console.Write("Deleting orphaned objects...");
                        foreach (string orphanedObject in orphanedObjects)
                        {
                            cache.DeleteItem(ItemCacheContainer.Objects, orphanedObject);
                        }

                        Console.WriteLine("Done.");
                    }
                }
            }
        }
Example #26
0
 /// <summary>
 /// Instantiates the basket
 /// </summary>
 /// <param name="customer">
 /// The customer.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <returns>
 /// The <see cref="IBasket"/>.
 /// </returns>
 internal static IBasket GetBasket(ICustomerBase customer, IItemCache itemCache)
 {
     return new Basket(itemCache, customer);
 }
Example #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasketSalePreparation"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <param name="customer">
 /// The customer.
 /// </param>
 internal BasketSalePreparation(IMerchelloContext merchelloContext, IItemCache itemCache, ICustomerBase customer)
     : base(merchelloContext, itemCache, customer)
 {
 }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WishList"/> class.
 /// </summary>
 /// <param name="itemCache">
 /// The item cache.
 /// </param>
 /// <param name="customer">
 /// The customer.
 /// </param>
 internal WishList(IItemCache itemCache, ICustomerBase customer)
     : base(itemCache, customer)
 {
     Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Wishlist, "itemCache");
 }