コード例 #1
0
ファイル: UnitTest.cs プロジェクト: SolidSnake74/SharpCore
 /// <summary>
 /// Handler for CommuniqueReceived events.
 /// </summary>
 /// <param name="sender">The server that received the communique.</param>
 /// <param name="e">Container for the communique data.</param>
 /// <remarks>This event should fire before the above SessionServer is disposed.</remarks>
 private void server_CommuniqueReceived(object sender, CommuniqueReceviedEventArgs e)
 {
     Communique communique = e.Communique;
     Assert.IsNotNull(communique);
     Assert.IsTrue(communique.ArrivedTime.ToShortDateString().Length > 0);
     Assert.IsTrue(communique.Body.ToString().Length > 0);
     Assert.IsTrue(communique.HostName.Length > 0);
     Assert.IsTrue(communique.SentTime.ToShortDateString().Length > 0);
 }
コード例 #2
0
        /// <summary>
        /// Handles the CommiqueReceived event raised by the configured SessionServer.  The specified CachedItem is added or updated within the local cache.
        /// </summary>
        /// <param name="sender">The SessionServer instance that fired the event.</param>
        /// <param name="e">A CommuniqueReceviedEventArgs instance that contains the CachedItem to be modified.</param>
        private void CommuniqueReceived(object sender, CommuniqueReceviedEventArgs e)
        {
            CachedItem item = (CachedItem) e.Communique.Body;

            if (cache.Exists(item.Key))
            {
                cache.Update(item.Key, item.Item);
            }
            else
            {
                cache.Add(item.Key, item.Item, item.AbsoluteExpiration, item.SlidingExpiration);
            }
        }