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


C# IProcedure4.Apply方法代码示例

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


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

示例1: Produce

		public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
			)
		{
			object value = _slots[key];
			if (value == null)
			{
				object newValue = producer.Apply(key);
				if (newValue == null)
				{
					return null;
				}
				if (_slots.Count >= _maxSize)
				{
					object discarded = Sharpen.Collections.Remove(_slots, _lru.RemoveLast());
					if (null != finalizer)
					{
						finalizer.Apply(discarded);
					}
				}
				_slots[key] = newValue;
				_lru.AddFirst(key);
				return newValue;
			}
			_lru.Remove(key);
			// O(N) 
			_lru.AddFirst(key);
			return value;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:28,代码来源:LRUCache.cs

示例2: AssertEventThrows

		private void AssertEventThrows(string eventName, ICodeBlock codeBlock, IProcedure4
			 listenerSetter)
		{
			IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(Db());
			listenerSetter.Apply(eventRegistry);
			Assert.Expect(typeof(EventException), typeof(NotImplementedException), codeBlock, 
				eventName);
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:8,代码来源:ExceptionPropagationInEventsTestUnit.cs

示例3: Discard

		private void Discard(long key, IProcedure4 finalizer)
		{
			if (null != finalizer)
			{
				finalizer.Apply(_slots[key]);
			}
			Sharpen.Collections.Remove(_slots, key);
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:8,代码来源:LRU2QLongCache.cs

示例4: ForEachField

		public static void ForEachField(IReflectClass claxx, IProcedure4 procedure)
		{
			while (claxx != null)
			{
				IReflectField[] declaredFields = claxx.GetDeclaredFields();
				for (int reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex)
				{
					IReflectField reflectField = declaredFields[reflectFieldIndex];
					procedure.Apply(reflectField);
				}
				claxx = claxx.GetSuperclass();
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:13,代码来源:ReflectorUtils.cs

示例5: AssertInconsistencyDetected

		private void AssertInconsistencyDetected(IProcedure4 proc)
		{
			IEmbeddedConfiguration config = NewConfiguration();
			LocalObjectContainer db = (LocalObjectContainer)Db4oEmbedded.OpenFile(config, TempFile
				());
			try
			{
				ConsistencyCheckerTestCase.Item item = new ConsistencyCheckerTestCase.Item();
				db.Store(item);
				db.Commit();
				Assert.IsTrue(new ConsistencyChecker(db).CheckSlotConsistency().Consistent());
				proc.Apply(new Pair(db, item));
				db.Commit();
				Assert.IsFalse(new ConsistencyChecker(db).CheckSlotConsistency().Consistent());
			}
			finally
			{
				db.Close();
			}
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:20,代码来源:ConsistencyCheckerTestCase.cs

示例6: Produce

		public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
			)
		{
			long longKey = (((long)key));
			if (_last == null)
			{
				object lastValue = producer.Apply(((long)key));
				if (lastValue == null)
				{
					return null;
				}
				_size = 1;
				LRULongCache.Entry lastEntry = new LRULongCache.Entry(longKey, lastValue);
				_slots.Put(longKey, lastEntry);
				_first = lastEntry;
				_last = lastEntry;
				return lastValue;
			}
			LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Get(longKey);
			if (entry == null)
			{
				if (_size >= _maxSize)
				{
					LRULongCache.Entry oldEntry = (LRULongCache.Entry)_slots.Remove(_last._key);
					_last = oldEntry._previous;
					_last._next = null;
					if (null != finalizer)
					{
						finalizer.Apply((object)oldEntry._value);
					}
					_size--;
				}
				object newValue = producer.Apply(((long)key));
				if (newValue == null)
				{
					return null;
				}
				_size++;
				LRULongCache.Entry newEntry = new LRULongCache.Entry(longKey, newValue);
				_slots.Put(longKey, newEntry);
				_first._previous = newEntry;
				newEntry._next = _first;
				_first = newEntry;
				return newValue;
			}
			if (_first == entry)
			{
				return ((object)entry._value);
			}
			LRULongCache.Entry previous = entry._previous;
			entry._previous = null;
			if (_last == entry)
			{
				_last = previous;
			}
			previous._next = entry._next;
			if (previous._next != null)
			{
				previous._next._previous = previous;
			}
			_first._previous = entry;
			entry._next = _first;
			_first = entry;
			return ((object)entry._value);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:65,代码来源:LRULongCache.cs

示例7: WithCache

 private void WithCache(IProcedure4 procedure)
 {
     IClientSlotCache clientSlotCache = null;
     try
     {
         clientSlotCache = (IClientSlotCache) Reflection4.GetFieldValue(Container(), "_clientSlotCache"
             );
     }
     catch (ReflectException e)
     {
         Assert.Fail("Can't get field _clientSlotCache on  container. " + e);
     }
     procedure.Apply(clientSlotCache);
 }
开发者ID:masroore,项目名称:db4o,代码行数:14,代码来源:ClientSlotCacheTestCase.cs

示例8: ForEachConstraint

		private void ForEachConstraint(IProcedure4 proc)
		{
			IEnumerator i = IterateConstraints();
			while (i.MoveNext())
			{
				QCon constraint = (QCon)i.Current;
				if (!constraint.ProcessedByIndex())
				{
					proc.Apply(constraint);
				}
			}
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:12,代码来源:QCandidates.cs

示例9: TraverseOwnSlots

		public virtual void TraverseOwnSlots(IProcedure4 block)
		{
			block.Apply(Pair.Of(0, _slot));
		}
开发者ID:superyfwy,项目名称:db4o,代码行数:4,代码来源:InMemoryIdSystem.cs

示例10: ProcessEachNode

		private void ProcessEachNode(IProcedure4 action)
		{
			if (_nodes == null)
			{
				return;
			}
			ProcessAllNodes();
			while (_processing.HasNext())
			{
				action.Apply((BTreeNode)_processing.Next());
			}
			_processing = null;
		}
开发者ID:erdincay,项目名称:db4o,代码行数:13,代码来源:BTree.cs

示例11: TraverseDeclaredAspects

 public virtual void TraverseDeclaredAspects(IProcedure4 procedure)
 {
     if (_aspects == null)
     {
         return;
     }
     for (var i = 0; i < _aspects.Length; i++)
     {
         procedure.Apply(_aspects[i]);
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:11,代码来源:ClassMetadata.cs

示例12: Discard

		private void Discard(object key, IProcedure4 finalizer)
		{
			object removed = Sharpen.Collections.Remove(_slots, key);
			if (finalizer != null)
			{
				finalizer.Apply(removed);
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:8,代码来源:LRU2QXCache.cs

示例13: TraverseDeclaredFields

		public virtual void TraverseDeclaredFields(IProcedure4 procedure)
		{
			if (_aspects == null)
			{
				return;
			}
			for (int i = 0; i < _aspects.Length; i++)
			{
				if (_aspects[i] is FieldMetadata)
				{
					procedure.Apply(_aspects[i]);
				}
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:14,代码来源:ClassMetadata.cs

示例14: Produce

 public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
     )
 {
     var intKey = (((int) key));
     if (_last == null)
     {
         var lastValue = producer.Apply(((int) key));
         if (lastValue == null)
         {
             return null;
         }
         _size = 1;
         var lastEntry = new Entry(intKey, lastValue);
         _slots.Put(intKey, lastEntry);
         _first = lastEntry;
         _last = lastEntry;
         return lastValue;
     }
     var entry = (Entry) _slots.Get(intKey);
     if (entry == null)
     {
         if (_size >= _maxSize)
         {
             var oldEntry = (Entry) _slots.Remove(_last._key);
             _last = oldEntry._previous;
             _last._next = null;
             if (null != finalizer)
             {
                 finalizer.Apply(oldEntry._value);
             }
             _size--;
         }
         var newValue = producer.Apply(((int) key));
         if (newValue == null)
         {
             return null;
         }
         _size++;
         var newEntry = new Entry(intKey, newValue);
         _slots.Put(intKey, newEntry);
         _first._previous = newEntry;
         newEntry._next = _first;
         _first = newEntry;
         return newValue;
     }
     if (_first == entry)
     {
         return entry._value;
     }
     var previous = entry._previous;
     entry._previous = null;
     if (_last == entry)
     {
         _last = previous;
     }
     previous._next = entry._next;
     if (previous._next != null)
     {
         previous._next._previous = previous;
     }
     _first._previous = entry;
     entry._next = _first;
     _first = entry;
     return entry._value;
 }
开发者ID:masroore,项目名称:db4o,代码行数:65,代码来源:LRUIntCache.cs

示例15: TraverseOwnSlots

 public virtual void TraverseOwnSlots(IProcedure4 block)
 {
     _parentIdSystem.TraverseOwnSlots(block);
     block.Apply(OwnSlotInfo(_persistentState.GetID()));
     block.Apply(OwnSlotInfo(_bTree.GetID()));
     var nodeIds = _bTree.AllNodeIds(_container.SystemTransaction());
     while (nodeIds.MoveNext())
     {
         block.Apply(OwnSlotInfo((((int) nodeIds.Current))));
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:11,代码来源:BTreeIdSystem.cs


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