예제 #1
0
            public override void SetValue(ContextItem value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }
                ContextItem valueNull;
                ContextItem previousItem = (valueNull = this.GetValueNull(value.ItemType)) ?? this.GetValue(value.ItemType);
                bool        flag         = false;

                try
                {
                    this._currentLayer.Items[value.ItemType] = value;
                    ContextItemManager.NotifyItemChanged(this._context, value, previousItem);
                    flag = true;
                }
                finally
                {
                    if (flag)
                    {
                        this.OnItemChanged(value);
                    }
                    else
                    {
                        this._currentLayer.Items.Remove(value.ItemType);
                        if (valueNull != null)
                        {
                            this.SetValue(valueNull);
                        }
                    }
                }
            }
예제 #2
0
            public override void Unsubscribe(Type contextItemType, SubscribeContextCallback callback)
            {
                if (contextItemType == null)
                {
                    throw new ArgumentNullException("contextItemType");
                }
                if (callback == null)
                {
                    throw new ArgumentNullException("callback");
                }
                if (!typeof(ContextItem).IsAssignableFrom(contextItemType))
                {
                    throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.Error_ArgIncorrectType, new object[2]
                    {
                        (object)"contextItemType",
                        (object)typeof(ContextItem).FullName
                    }));
                }
                SubscribeContextCallback subscribeContextCallback1;

                if (this._subscriptions == null || !this._subscriptions.TryGetValue(contextItemType, out subscribeContextCallback1))
                {
                    return;
                }
                SubscribeContextCallback subscribeContextCallback2 = (SubscribeContextCallback)ContextItemManager.RemoveCallback((Delegate)subscribeContextCallback1, (Delegate)callback);

                if (subscribeContextCallback2 == null)
                {
                    this._subscriptions.Remove(contextItemType);
                }
                else
                {
                    this._subscriptions[contextItemType] = subscribeContextCallback2;
                }
            }