Ejemplo n.º 1
0
        public void Unlink()
        {
            if(!IsLinked)
                return;

            if(_compound != null)
            {
                _compound._Unlink(this);
            }
            _compound = null;
        }
Ejemplo n.º 2
0
        private void _linkInto(ApplicationCompound targetCompound)
        {
            var oldCompound = _compound;
            if(IsLinked)
            {
                Debug.Assert(oldCompound != null);
                var newCache = oldCompound.Cache.LinkInto(targetCompound.Cache);
                oldCompound.Cache = newCache;
                targetCompound.Cache = newCache;

                foreach (var linkedApp in oldCompound)
                {
                    linkedApp._compound = targetCompound;
                    targetCompound._Link(linkedApp);
                }
                
                oldCompound._Clear();
            }
            else
            {
                if (oldCompound != null)
                {
                    targetCompound.Cache = oldCompound.Cache.LinkInto(targetCompound.Cache);
                    oldCompound._Clear();
                }
                _compound = targetCompound;
                targetCompound._Link(this);
            }
            Debug.Assert(ReferenceEquals(_compound, targetCompound), "_linkInto didn't catch the receiving Application.");
        }