Esempio n. 1
0
        /// <summary>
        /// Raises the RealizeContext event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void OnConnectionEstablishContext(object sender, AddressBookItemConnectionManagerContextEventArgs e)
        {
            try
            {
                // first check and see if we've already got a context bound to this item
                IAddressBookItemContext context = this.LookupContextForItem(e.Manager.AddressBookItem);

                // if we have a pre-bound context put it in the event args!
                if (context != null)
                {
                    e.Context = context;
                }

                // if there are any event handler's to fire this event to
                if (this.ConnectionEstablishContext != null)
                {
                    // raise the event
                    this.ConnectionEstablishContext(sender, e);

                    // if a context was returned to us, bind the item to the context
                    if (e.Context != null)
                    {
                        this.BindContextToItem(e.Manager.AddressBookItem, e.Context);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Allow the client to realize the context for this address book item (aka, manifest the item visually and store some state information in our context for later reference)
        /// </summary>
        private void InternalEstablishContext()
        {
            /*
             * Raise the realize context event, and save the context supplied to us by the client
             * */
            AddressBookItemConnectionManagerContextEventArgs e = new AddressBookItemConnectionManagerContextEventArgs(this);

            this.OnConnectionEstablishContext(this, e);

            // save the supplied context
            _itemContext = e.Context;

            // if the context is supplied, then set the context's item property reference to the address book item we are managing
            if (_itemContext != null)
            {
                _itemContext.AddressBookItem = _item;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Allows a context to be pre-bound to an item so that the estabilish context event will already contain the context
        /// </summary>
        /// <param name="item"></param>
        /// <param name="context"></param>
        public virtual void BindContextToItem(AddressBookItem item, IAddressBookItemContext context)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            lock (_contextLookupTable)
            {
                if (_contextLookupTable.ContainsKey(item))
                {
                    _contextLookupTable[item] = context;
                }
                else
                {
                    _contextLookupTable.Add(item, context);
                }
            }
        }
		/// <summary>
		/// Allow the client to realize the context for this address book item (aka, manifest the item visually and store some state information in our context for later reference)
		/// </summary>
		private void InternalEstablishContext()
		{	
			/*
			 * Raise the realize context event, and save the context supplied to us by the client
			 * */
			AddressBookItemConnectionManagerContextEventArgs e = new AddressBookItemConnectionManagerContextEventArgs(this);			
			this.OnConnectionEstablishContext(this, e);
			
			// save the supplied context
			_itemContext = e.Context;
			
			// if the context is supplied, then set the context's item property reference to the address book item we are managing
			if (_itemContext != null)
				_itemContext.AddressBookItem = _item;
		}
		/// <summary>
		/// Allows a context to be pre-bound to an item so that the estabilish context event will already contain the context
		/// </summary>
		/// <param name="item"></param>
		/// <param name="context"></param>
		public virtual void BindContextToItem(AddressBookItem item, IAddressBookItemContext context)
		{
			if (item == null)
				throw new ArgumentNullException("item");

			if (context == null)
				throw new ArgumentNullException("context");

			lock(_contextLookupTable)
			{
				if (_contextLookupTable.ContainsKey(item))
					_contextLookupTable[item] = context;
				else
					_contextLookupTable.Add(item, context);
			}
		}