示例#1
0
        /// <summary>
        /// Received an XDB element on Component.
        /// Is this a response to a tracked request?
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="xdb"></param>
        private void OnXdb(object sender, Xdb xdb)
        {
            string id = xdb.ID;
            TrackerData td;

            lock (m_pending)
            {
                td = (TrackerData) m_pending[id];

                // this wasn't one that was being tracked.
                if (td == null)
                {
                    return;
                }
                m_pending.Remove(id);
            }

            // don't need to check for null.  protected by assert below.
            td.cb(this, xdb, td.data);
        }
示例#2
0
 /// <summary>
 /// Start an XDB request.
 /// </summary>
 /// <param name="root"></param>
 /// <param name="xtype"></param>
 /// <param name="owner"></param>
 /// <param name="ns"></param>
 /// <param name="action"></param>
 /// <param name="cb"></param>
 /// <param name="cbArg"></param>
 public void BeginXdb(XmlElement root, XdbType xtype,
     string owner, string ns, XdbAction action,
     XdbCB cb, object cbArg)
 {
     Debug.Assert(owner != null);
     Debug.Assert(ns    != null);
     Xdb xdb  = new Xdb(m_comp.Document);
     xdb.NS   = ns;
     xdb.Type = xtype;
     xdb.To   = owner;
     xdb.From = m_comp.ComponentID;
     if (action != XdbAction.NONE)
         xdb.Action = action;
     if (root != null)
         xdb.AddChild(root);
     // if no callback, ignore response.
     if (cb != null)
     {
         TrackerData td = new TrackerData();
         td.cb   = cb;
         td.data = cbArg;
         lock (m_pending)
         {
             m_pending[xdb.ID] = td;
         }
     }
     m_comp.Write(xdb);
 }