当前位置: 首页>>代码示例>>C#>>正文


C# EventContext.HasEventID方法代码示例

本文整理汇总了C#中EventContext.HasEventID方法的典型用法代码示例。如果您正苦于以下问题:C# EventContext.HasEventID方法的具体用法?C# EventContext.HasEventID怎么用?C# EventContext.HasEventID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventContext的用法示例。


在下文中一共展示了EventContext.HasEventID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RaiseCustomRemoveCalbackNotifier

        /// <summary>
        /// Reaises the custom item remove call baack.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="cbEntry"></param>
        internal void RaiseCustomRemoveCalbackNotifier(object key, CacheEntry cacheEntry, ItemRemoveReason reason, bool async, OperationContext operationContext, EventContext eventContext)
        {
            ArrayList destinations = null;
            ArrayList nodes = null;
            Hashtable intendedNotifiers = new Hashtable();
            CallbackEntry cbEntry = cacheEntry.Value as CallbackEntry;

            if (cbEntry != null && cbEntry.ItemRemoveCallbackListener.Count > 0)
            {
                if (_stats.Nodes != null)
                {
                    nodes = _stats.Nodes.Clone() as ArrayList;

                    destinations = new ArrayList();
                    foreach (CallbackInfo cbInfo in cbEntry.ItemRemoveCallbackListener)
                    {
                        if (reason == ItemRemoveReason.Expired && cbInfo != null && !cbInfo.NotifyOnExpiration)
                            continue;

                        int index = nodes.IndexOf(new NodeInfo(Cluster.LocalAddress));
                        if (index != -1 && ((NodeInfo)nodes[index]).ConnectedClients.Contains(cbInfo.Client))
                        {
                            if (!destinations.Contains(Cluster.LocalAddress))
                            {
                                destinations.Add(Cluster.LocalAddress);
                            }
                            intendedNotifiers[cbInfo] = Cluster.LocalAddress;
                            continue;
                        }
                        else
                        {
                            foreach (NodeInfo nInfo in nodes)
                            {
                                if (nInfo.ConnectedClients != null && nInfo.ConnectedClients.Contains(cbInfo.Client))
                                {
                                    if (!destinations.Contains(nInfo.Address))
                                    {
                                        destinations.Add(nInfo.Address);
                                        intendedNotifiers[cbInfo] = nInfo.Address;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (destinations != null && destinations.Count > 0)
            {
                if (operationContext == null) operationContext = new OperationContext();

                if (eventContext == null || !eventContext.HasEventID(EventContextOperationType.CacheOperation))
                {
                    eventContext = CreateEventContext(operationContext, Persistence.EventType.ITEM_REMOVED_CALLBACK);
                    eventContext.Item = CacheHelper.CreateCacheEventEntry(cbEntry.ItemRemoveCallbackListener, cacheEntry);
                    eventContext.Add(EventContextFieldName.ItemRemoveCallbackList, cbEntry.ItemRemoveCallbackListener.Clone());
                }

                object[] packed = new object[] { key, reason, intendedNotifiers, operationContext, eventContext };
                ///Incase of parition, there can be same clients connected
                ///to multiple server. therefore the destinations list will contain more then 
                ///one servers. so the callback will be sent to the same client through different server
                ///to avoid this, we will check the list for local server. if client is connected with
                ///local node, then there is no need to send callback to all other nodes
                ///if there is no local node, then we select the first node in the list.
                RaiseCustomRemoveCalbackNotifier(destinations, packed, async);
            }

        }
开发者ID:christrotter,项目名称:NCache,代码行数:74,代码来源:ClusterCacheBase.cs


注:本文中的EventContext.HasEventID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。