Ejemplo n.º 1
0
        private void SetOwnerCore(CharacteristicObject newOwner)
        {
            if (newOwner == null)
            {
                throw new ArgumentNullException(nameof(newOwner));
            }

            AssertNotFrozen();
            newOwner.AssertIsNonFrozenRoot();

            Owner        = newOwner;
            sharedValues = newOwner.sharedValues;
            frozen       = false;
        }
Ejemplo n.º 2
0
        private void AttachToOwner(CharacteristicObject newOwner, Characteristic thisCharacteristic)
        {
            if (newOwner == null)
            {
                throw new ArgumentNullException(nameof(newOwner));
            }
            if (IsPropertyBag)
            {
                throw new InvalidOperationException(
                          $"The property bag {this} cannot be used as characteristic's value.");
            }

            AssertIsNonFrozenRoot();
            newOwner.AssertIsNonFrozenRoot();

            var oldValues = sharedValues;

            newOwner.SetValueOnAttach(thisCharacteristic, this);
            foreach (var pair in oldValues)
            {
                newOwner.SetValueOnAttach(pair.Key, pair.Value);
            }
        }