Пример #1
0
        public OtherNode Copy(OtherNode node)
        {
            var result          = new OtherNode();
            var basketCountries = node.GetBasketCountries();

            foreach (var basketCountry in basketCountries)
            {
                var copied = this.Copy(basketCountry);
                result.RegisterResident(copied);
            }
            return(result);
        }
Пример #2
0
        protected OtherNode ReadOtherNode(IElement element, BasketRepository basketRepository, CountryRepository countryRepository)
        {
            var result = new OtherNode();

            if (!element.IsAtomic)
            {
                var someElementOpt = element.TryLockOn(BasketCountryElementName);
                while (someElementOpt != null)
                {
                    var basketCountry = this.ReadBasketCountryNode(someElementOpt, basketRepository);
                    result.RegisterResident(basketCountry);
                    someElementOpt = someElementOpt.ReleaseAndTryLockOnNext(someElementOpt.Name);
                }
            }
            return(result);
        }
Пример #3
0
        protected OtherNode ReadOtherNode(BasketRepository basketRepository, IElement element)
        {
            var expectedElementNames = new String[] { BasketCountryElementName, UnsavedBasketCountryElementName };
            var result = new OtherNode();

            if (!element.IsAtomic)
            {
                var someElementOpt = element.TryMultiLockOn(expectedElementNames);
                while (someElementOpt != null)
                {
                    IOtherNodeResident resident;
                    switch (someElementOpt.Name)
                    {
                    case BasketCountryElementName:
                    {
                        var basketCountry = this.ReadBasketCountryNode(basketRepository, someElementOpt);
                        resident = basketCountry;
                        break;
                    }

                    case UnsavedBasketCountryElementName:
                    {
                        var unsavedBasketCountry = this.ReadUnsavedBasketCountry(someElementOpt);
                        resident = unsavedBasketCountry;
                        break;
                    }

                    default: throw new ApplicationException("Unexpected element name: " + someElementOpt.Name);
                    }

                    result.RegisterResident(resident);
                    someElementOpt = someElementOpt.ReleaseAndTryMultiLockOnNext(someElementOpt.Name, expectedElementNames);
                }
            }
            return(result);
        }