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


C# OperationContext.RemoveValueByField方法代码示例

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


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

示例1: Remove

        /// <summary>
        /// Removes key and value pairs from the cache. The keys are specified as parameter.
        /// Moreover it take a removal reason and a boolean specifying if a notification should
        /// be raised.
        /// </summary>
        /// <param name="keys">keys of the entry.</param>
        /// <param name="removalReason">reason for the removal.</param>
        /// <param name="notify">boolean specifying to raise the event.</param>
        /// <returns>list of removed keys</returns>
        public override Hashtable Remove(object[] keys, ItemRemoveReason removalReason, bool notify, bool isUserOperation, OperationContext operationContext)
        {
            Hashtable table = new Hashtable();
            EventContext eventContext = null;
            EventId eventId = null;
            OperationID opId = operationContext.OperatoinID;
            for (int i = 0; i < keys.Length; i++)
            {
                try
                {
                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                    if (notify)
                    {
                        //generate EventId
                        eventId = new EventId();
                        eventId.EventUniqueID = opId.OperationId;
                        eventId.OperationCounter = opId.OpCounter;
                        eventId.EventCounter = i;
                        eventContext = new EventContext();
                        eventContext.Add(EventContextFieldName.EventID, eventId);
                        operationContext.Add(OperationContextFieldName.EventContext, eventContext);
                    }
                    CacheEntry e = Remove(keys[i], removalReason, notify, null, LockAccessType.IGNORE_LOCK, operationContext);
                    if (e != null)
                    {
                        table[keys[i]] = e;
                    }
                }              
                catch (StateTransferException e)
                {
                    table[keys[i]] = e;
                }
                finally
                {
                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                }
            }


            if (_context.PerfStatsColl != null)
            {
                _context.PerfStatsColl.SetCacheSize(Size);
            }

            return table;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:55,代码来源:LocalCacheBase.cs

示例2: Insert

        /// <summary>
        /// Adds key and value pairs to the cache. If any of the specified keys 
        /// already exists in the cache; it is updated, otherwise a new item is 
        /// added to the cache.
        /// </summary>
        /// <param name="keys">keys of the entries.</param>
        /// <param name="cacheEntry">the cache entries.</param>
        /// <returns>returns keys that are added or updated successfully and their status.</returns>
        public sealed override Hashtable Insert(object[] keys, CacheEntry[] cacheEntries, bool notify, OperationContext operationContext)
        {
            Hashtable table = new Hashtable();
            EventContext eventContext = null;
            EventId eventId = null;
            OperationID opId = operationContext.OperatoinID;
            for (int i = 0; i < keys.Length; i++)
            {
                try
                {
                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                    if (notify)
                    {
                        //generate EventId
                        eventId = new EventId();
                        eventId.EventUniqueID = opId.OperationId;
                        eventId.OperationCounter = opId.OpCounter;
                        eventId.EventCounter = i;
                        eventContext = new EventContext();
                        eventContext.Add(EventContextFieldName.EventID, eventId);
                        operationContext.Add(OperationContextFieldName.EventContext, eventContext);
                    }
                    CacheInsResultWithEntry result = Insert(keys[i], cacheEntries[i], notify, null, LockAccessType.IGNORE_LOCK, operationContext);
                    table.Add(keys[i], result);
                }
                catch (Exception e)
                {
                    table[keys[i]] = e;
                }
                finally
                {
                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                }
            }

            if (_context.PerfStatsColl != null)
            {
                _context.PerfStatsColl.SetCacheSize(Size);
            }

            return table;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:50,代码来源:LocalCacheBase.cs

示例3: Get

        /// <summary>
        /// Retrieve the objects from the cache.
        /// An array of keys is passed as parameter.
        /// </summary>
        /// <param name="keys">keys of the entries.</param>
        /// <returns>key and entry pairs.</returns>
        public sealed override Hashtable Get(object[] keys, OperationContext operationContext)
        {
            Hashtable entries = new Hashtable();
            CacheEntry e = null;
            for (int i = 0; i < keys.Length; i++)
            {
                try
                {
                    
                    if(operationContext != null)
                    {
                        operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                        OperationID opId = operationContext.OperatoinID;
                        //generate EventId
                        EventId eventId = EventId.CreateEventId(opId);
                        eventId.EventUniqueID = opId.OperationId;
                        eventId.OperationCounter = opId.OpCounter;
                        eventId.EventCounter = i;
                        EventContext eventContext = new EventContext();
                        eventContext.Add(EventContextFieldName.EventID, eventId);
                        operationContext.Add(OperationContextFieldName.EventContext, eventContext);
                    }

                    e = Get(keys[i], operationContext);
                    if (e != null)
                    {
                        entries[keys[i]] = e;
                    }
                }
                catch (StateTransferException se)
                {
                    entries[keys[i]] = se;
                }
            }
            return entries;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:42,代码来源:LocalCacheBase.cs

示例4: Add

        /// <summary>
        /// Adds key and value pairs to the cache. Throws an exception or returns the
        /// list of keys that failed to add in the cache.
        /// </summary>
        /// <param name="keys">keys of the entries.</param>
        /// <param name="cacheEntries">the cache entries.</param>
        /// <returns>List of keys that are added or that alredy exists in the cache and their status.</returns>
        public sealed override Hashtable Add(object[] keys, CacheEntry[] cacheEntries, bool notify, OperationContext operationContext)
        {

            Hashtable table = new Hashtable();
            EventContext eventContext = null;
            EventId eventId = null;
            OperationID opId = operationContext.OperatoinID;
            for (int i = 0; i < keys.Length; i++)
            {
                try
                {

                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                    if (notify)
                    {
                        //generate EventId
                        eventId = new EventId();
                        eventId.EventUniqueID = opId.OperationId;
                        eventId.OperationCounter = opId.OpCounter;
                        eventId.EventCounter = i;
                        eventContext = new EventContext();
                        eventContext.Add(EventContextFieldName.EventID, eventId);
                        operationContext.Add(OperationContextFieldName.EventContext, eventContext);
                    }
                    CacheAddResult result = Add(keys[i], cacheEntries[i], notify, operationContext);
                    table[keys[i]] = result;
                }
                catch (Exceptions.StateTransferException se)
                {
                    table[keys[i]] = se;
                }
                catch (Exception inner)
                {
                    table[keys[i]] = new OperationFailedException(inner.Message, inner);
                }
                finally 
                {
                    operationContext.RemoveValueByField(OperationContextFieldName.EventContext);
                }
            }

            if (_context.PerfStatsColl != null)
            {
                _context.PerfStatsColl.SetCacheSize(Size);
            }
            return table;
        }
开发者ID:christrotter,项目名称:NCache,代码行数:54,代码来源:LocalCacheBase.cs

示例5: ClusteredInsert


//.........这里部分代码省略.........
                            for (int i = 0; i < currentKeys.Length; i++)
                            {
                                tmpResult[currentKeys[i]] = new GeneralFailureException(te.Message, te);
                            }
                        }
                        catch (BucketTransferredException ex)
                        {
                            tmpResult = new Hashtable();
                            for (int i = 0; i < currentKeys.Length; i++)
                            {
                                tmpResult[currentKeys[i]] = new OperationFailedException(ex.Message, ex);
                            }
                        }

                        if (tmpResult != null && tmpResult.Count > 0)
                        {
                            IDictionaryEnumerator ie = tmpResult.GetEnumerator();
                            while (ie.MoveNext())
                            {
                                if (ie.Value is StateTransferException)
                                {
                                    totalRemainingKeys[ie.Key] = null;
                                }
                                else
                                {
                                    if (ie.Value is Exception)
                                    {
                                        result[ie.Key] = ie.Value;
                                    }
                                    else if (ie.Value is CacheInsResultWithEntry)
                                    {
                                        CacheInsResultWithEntry res = ie.Value as CacheInsResultWithEntry;
                                        switch (res.Result)
                                        {
                                            case CacheInsResult.Failure:
                                                result[ie.Key] =
                                                    new OperationFailedException(
                                                        "Generic operation failure; not enough information is available.");
                                                break;
                                            case CacheInsResult.NeedsEviction:
                                                result[ie.Key] =
                                                    new OperationFailedException(
                                                        "The cache is full and not enough items could be evicted.");
                                                break;
                                            case CacheInsResult.Success:
                                                totalAddedKeys[ie.Key] = null;
                                                break;
                                            case CacheInsResult.SuccessOverwrite:
                                                totalInsertedKeys[ie.Key] = ie.Value;
                                                result[ie.Key] = ie.Value;
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                keysToInsert = new ArrayList(totalRemainingKeys.Keys);
                totalRemainingKeys.Clear();
            } while (keysToInsert.Count > 0);

            object generateQueryInfo = operationContext.GetValueByField(OperationContextFieldName.GenerateQueryInfo);
            if (generateQueryInfo == null)
            {
                operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true);
            }

            if (totalInsertedKeys.Count > 0)
            {
                IDictionaryEnumerator ide = totalInsertedKeys.GetEnumerator();
                while (ide.MoveNext())
                {
                    object key = ide.Key;
                    CacheInsResultWithEntry insResult = ide.Value as CacheInsResultWithEntry;
                    if (notify)
                    {
                        CacheEntry currentEntry = fullEntrySet[(string) ide.Key];
                        object value = insResult.Entry.Value;
                        if (value is CallbackEntry)
                        {

                            RaiseCustomUpdateCalbackNotifier(ide.Key, currentEntry, insResult.Entry, operationContext);
                        }
                    }
                }

            }



            if (generateQueryInfo == null)
            {
                operationContext.RemoveValueByField(OperationContextFieldName.GenerateQueryInfo);
            }


            return result;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:101,代码来源:PartitionedServerCache.cs


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