Example #1
0
 private void DeleteAndReadd(IObjectContainer db, Collection4 removed)
 {
     var removeIter = removed.GetEnumerator();
     while (removeIter.MoveNext())
     {
         db.Delete(removeIter.Current);
     }
     db.Commit();
     var readdIter = removed.GetEnumerator();
     while (readdIter.MoveNext())
     {
         db.Store(readdIter.Current);
     }
     db.Commit();
 }
		public virtual void TestSeries()
		{
			Collection4 calls = new Collection4();
			IEnumerator series = Iterators.Series(string.Empty, new _IFunction4_11(calls)).GetEnumerator
				();
			Assert.IsTrue(series.MoveNext());
			Assert.IsTrue(series.MoveNext());
			Iterator4Assert.AreEqual(new object[] { string.Empty, "*" }, calls.GetEnumerator(
				));
		}
Example #3
0
		public virtual void TraverseMutable(IVisitor4 visitor)
		{
			Collection4 currentContent = new Collection4();
			TraverseLocked(new _IVisitor4_51(currentContent));
			IEnumerator i = currentContent.GetEnumerator();
			while (i.MoveNext())
			{
				visitor.Visit(i.Current);
			}
		}
		private CompositeIterator4 NewIterator()
		{
			Collection4 iterators = new Collection4();
			iterators.Add(IntArrays4.NewIterator(new int[] { 1, 2, 3 }));
			iterators.Add(IntArrays4.NewIterator(new int[] {  }));
			iterators.Add(IntArrays4.NewIterator(new int[] { 4 }));
			iterators.Add(IntArrays4.NewIterator(new int[] { 5, 6 }));
			CompositeIterator4 iterator = new CompositeIterator4(iterators.GetEnumerator());
			return iterator;
		}
		public virtual void Run()
		{
			dontRemove = true;
			Collection4 copy = new Collection4(_containers);
			IEnumerator i = copy.GetEnumerator();
			while (i.MoveNext())
			{
				((ObjectContainerBase)i.Current).ShutdownHook();
			}
		}
Example #6
0
		public virtual IEnumerator IteratorFor(object collection)
		{
			IDictionary map = (IDictionary)collection;
			Collection4 result = new Collection4();
			IEnumerator it = map.GetEnumerator();
			while (it.MoveNext())
			{
				DictionaryEntry entry = (DictionaryEntry)it.Current;
				result.Add(entry.Key);
				result.Add(entry.Value);
			}
			return result.GetEnumerator();
		}
Example #7
0
        public static IEnumerator Iterate(List4 list)
        {
            if (list == null)
            {
                return(EmptyIterator);
            }
            Collection4 collection = new Collection4();

            while (list != null)
            {
                collection.Add(list._element);
                list = ((List4)list._next);
            }
            return(collection.GetEnumerator());
        }
 /// <exception cref="System.Exception"></exception>
 public virtual void TestClose()
 {
     var container = Db();
     var session = FileSession();
     var actual = new Collection4();
     EventRegistry().Closing += new _IEventListener4_21(actual).OnEvent;
     Fixture().Close();
     if (IsEmbedded())
     {
         Iterator4Assert.AreEqual(new object[] {container, session}, actual.GetEnumerator
             ());
     }
     else
     {
         Assert.AreSame(container, actual.SingleElement());
     }
 }
		/// <exception cref="System.Exception"></exception>
		public virtual void TestClose()
		{
			IExtObjectContainer container = Db();
			LocalObjectContainer session = FileSession();
			Collection4 actual = new Collection4();
			EventRegistry().Closing += new System.EventHandler<Db4objects.Db4o.Events.ObjectContainerEventArgs>
				(new _IEventListener4_21(actual).OnEvent);
			Fixture().Close();
			if (IsEmbedded())
			{
				Iterator4Assert.AreEqual(new object[] { container, session }, actual.GetEnumerator
					());
			}
			else
			{
				Assert.AreSame(container, actual.SingleElement());
			}
		}
		public void WriteAllClasses()
		{
			Collection4 deadClasses = new Collection4();
			IStoredClass[] storedClasses = StoredClasses();
			for (int i = 0; i < storedClasses.Length; i++)
			{
				ClassMetadata clazz = (ClassMetadata)storedClasses[i];
				clazz.SetStateDirty();
				if (clazz.StateDead())
				{
					deadClasses.Add(clazz);
					clazz.SetStateOK();
				}
			}
			for (int i = 0; i < storedClasses.Length; i++)
			{
				ClassMetadata clazz = (ClassMetadata)storedClasses[i];
				clazz.Write(_systemTransaction);
			}
			IEnumerator it = deadClasses.GetEnumerator();
			while (it.MoveNext())
			{
				((ClassMetadata)it.Current).SetStateDead();
			}
		}
			public ClassIDIterator(Collection4 classes) : base(classes.GetEnumerator())
			{
			}
		private void EnsureAllClassesRead()
		{
			bool allClassesRead = false;
			while (!allClassesRead)
			{
				Collection4 unreadClasses = new Collection4();
				int numClasses = _classes.Size();
				IEnumerator classIter = _classes.GetEnumerator();
				while (classIter.MoveNext())
				{
					ClassMetadata clazz = (ClassMetadata)classIter.Current;
					if (clazz.StateUnread())
					{
						unreadClasses.Add(clazz);
					}
				}
				IEnumerator unreadIter = unreadClasses.GetEnumerator();
				while (unreadIter.MoveNext())
				{
					ClassMetadata clazz = (ClassMetadata)unreadIter.Current;
					clazz = ReadClassMetadata(clazz, null);
					if (clazz.ClassReflector() == null)
					{
						clazz.ForceRead();
					}
				}
				allClassesRead = (_classes.Size() == numClasses);
			}
			ApplyReadAs();
		}
Example #13
0
 private bool Contains(Collection4 collectedAspects, FieldMetadata field)
 {
     var aspectIterator = collectedAspects.GetEnumerator();
     while (aspectIterator.MoveNext())
     {
         if (((ClassAspect) aspectIterator.Current).Equals(field))
         {
             return true;
         }
     }
     return false;
 }
		/// <exception cref="System.Exception"></exception>
		public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock
			 block)
		{
			LocalObjectContainer container = (LocalObjectContainer)trans.Container();
			ITransactionalIdSystem idSystem = trans.IdSystem();
			IEnumerator allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction());
			Collection4 allSlots = new Collection4();
			while (allSlotIDs.MoveNext())
			{
				int slotID = ((int)allSlotIDs.Current);
				Slot slot = idSystem.CurrentSlot(slotID);
				allSlots.Add(slot);
			}
			Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID());
			allSlots.Add(bTreeSlot);
			Collection4 freedSlots = new Collection4();
			IFreespaceManager freespaceManager = container.FreespaceManager();
			container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99
				(freedSlots)));
			block.Run();
			container.InstallDebugFreespaceManager(freespaceManager);
			Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator()));
		}
Example #15
0
		public static IEnumerator Iterate(List4 list)
		{
			if (list == null)
			{
				return EmptyIterator;
			}
			Collection4 collection = new Collection4();
			while (list != null)
			{
				collection.Add(list._element);
				list = ((List4)list._next);
			}
			return collection.GetEnumerator();
		}
Example #16
0
		internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon ProduceTopLevelJoin
			()
		{
			if (!HasJoins())
			{
				return this;
			}
			IEnumerator i = IterateJoins();
			if (i_joins.Size() == 1)
			{
				i.MoveNext();
				return ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).ProduceTopLevelJoin
					();
			}
			Collection4 col = new Collection4();
			while (i.MoveNext())
			{
				col.Ensure(((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).ProduceTopLevelJoin
					());
			}
			i = col.GetEnumerator();
			i.MoveNext();
			Db4objects.Db4o.Internal.Query.Processor.QCon qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon
				)i.Current;
			if (col.Size() == 1)
			{
				return qcon;
			}
			while (i.MoveNext())
			{
				qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon)qcon.And((IConstraint)i.Current
					);
			}
			return qcon;
		}
Example #17
0
 public virtual IEnumerator ExecuteSnapshot()
 {
     var r = CreateCandidateCollection();
     var executionPath = ExecutionPath(r);
     IEnumerator candidatesIterator = new Iterator4Impl(r.candidateCollection);
     var snapshots = new Collection4();
     while (candidatesIterator.MoveNext())
     {
         var candidates = (QCandidates) candidatesIterator.Current;
         snapshots.Add(candidates.ExecuteSnapshot(executionPath));
     }
     var snapshotsIterator = snapshots.GetEnumerator();
     var resultingIDs = new CompositeIterator4(snapshotsIterator);
     if (!r.checkDuplicates)
     {
         return resultingIDs;
     }
     return CheckDuplicates(resultingIDs);
 }
Example #18
0
		private bool AllHaveSamePath(Collection4 leaves)
		{
			IEnumerator i = leaves.GetEnumerator();
			i.MoveNext();
			QCon first = (QCon)i.Current;
			while (i.MoveNext())
			{
				if (!HaveSamePath(first, (QCon)i.Current))
				{
					return false;
				}
			}
			return true;
		}
Example #19
0
		public virtual IEnumerator AllNodeIds(Transaction systemTrans)
		{
			Collection4 allNodeIDs = new Collection4();
			TraverseAllNodes(systemTrans, new _IVisitor4_527(allNodeIDs));
			return allNodeIDs.GetEnumerator();
		}
		private void AssertEntries(PersistentEntry[] expected, IEnumerator actual)
		{
			Collection4 checklist = new Collection4(actual);
			Assert.AreEqual(expected.Length, checklist.Size());
			for (int i = 0; i < expected.Length; ++i)
			{
				PersistentEntry e = expected[i];
				PersistentEntry a = EntryByUid(checklist.GetEnumerator(), e.uid);
				if (a != null)
				{
					AssertEqualEntries(e, a);
					checklist.Remove(a);
				}
			}
			Assert.IsTrue(checklist.IsEmpty(), checklist.ToString());
		}
Example #21
0
		private void AssertCollection(string[] expected, Collection4 c)
		{
			Assert.AreEqual(expected.Length, c.Size());
			Iterator4Assert.AreEqual(expected, c.GetEnumerator());
		}
Example #22
0
 private void DisableAspectsBefore(Collection4 aspects, TypeHandlerAspect typeHandlerAspect
     )
 {
     var disableFromVersion = aspects.IndexOf(typeHandlerAspect) + 1;
     var i = aspects.GetEnumerator();
     while (i.MoveNext())
     {
         var aspect = (ClassAspect) i.Current;
         if (aspect == typeHandlerAspect)
         {
             break;
         }
         aspect.DisableFromAspectCountVersion(disableFromVersion);
     }
 }
Example #23
0
		private IEnumerator MapIdsToExecutionPath(IEnumerator singleObjectQueryIterator, 
			Collection4 executionPath)
		{
			if (executionPath == null)
			{
				return singleObjectQueryIterator;
			}
			IEnumerator res = singleObjectQueryIterator;
			IEnumerator executionPathIterator = executionPath.GetEnumerator();
			while (executionPathIterator.MoveNext())
			{
				string fieldName = (string)executionPathIterator.Current;
				res = Iterators.Concat(Iterators.Map(res, new _IFunction4_205(this, fieldName)));
			}
			return res;
		}
Example #24
0
		internal virtual void CreateCandidates(Collection4 a_candidateCollection)
		{
			IEnumerator j = a_candidateCollection.GetEnumerator();
			while (j.MoveNext())
			{
				QCandidates candidates = (QCandidates)j.Current;
				if (candidates.TryAddConstraint(this))
				{
					i_candidates = candidates;
					return;
				}
			}
			i_candidates = new QCandidates((LocalTransaction)i_trans, GetYapClass(), GetField
				(), false);
			i_candidates.AddConstraint(this);
			a_candidateCollection.Add(i_candidates);
		}
Example #25
0
		private bool AllCanBeSearchedByIndex(Collection4 leaves)
		{
			IEnumerator i = leaves.GetEnumerator();
			while (i.MoveNext())
			{
				QCon leaf = ((QCon)i.Current);
				if (!leaf.CanLoadByIndex())
				{
					return false;
				}
			}
			return true;
		}
Example #26
0
		internal virtual IConstraint Join1(Db4objects.Db4o.Internal.Query.Processor.QCon 
			a_with, bool a_and)
		{
			if (a_with is QConstraints)
			{
				int j = 0;
				Collection4 joinHooks = new Collection4();
				IConstraint[] constraints = ((QConstraints)a_with).ToArray();
				for (j = 0; j < constraints.Length; j++)
				{
					joinHooks.Ensure(((Db4objects.Db4o.Internal.Query.Processor.QCon)constraints[j]).
						JoinHook());
				}
				IConstraint[] joins = new IConstraint[joinHooks.Size()];
				j = 0;
				IEnumerator i = joinHooks.GetEnumerator();
				while (i.MoveNext())
				{
					joins[j++] = Join((IConstraint)i.Current, a_and);
				}
				return new QConstraints(i_trans, joins);
			}
			Db4objects.Db4o.Internal.Query.Processor.QCon myHook = JoinHook();
			Db4objects.Db4o.Internal.Query.Processor.QCon otherHook = a_with.JoinHook();
			if (myHook == otherHook)
			{
				// You might like to check out, what happens, if you
				// remove this line. It seems to open a bug in an
				// StOr testcase.
				return myHook;
			}
			QConJoin cj = new QConJoin(i_trans, myHook, otherHook, a_and);
			myHook.AddJoin(cj);
			otherHook.AddJoin(cj);
			return cj;
		}
Example #27
0
		private void CollectImplicitlyAndingJoins(Collection4 joins, QConObject constraintWithJoins
			)
		{
			IEnumerator i = joins.GetEnumerator();
			i.MoveNext();
			IIndexedNodeWithRange last = NodeForConstraint((QCon)i.Current);
			while (i.MoveNext())
			{
				IIndexedNodeWithRange node = NodeForConstraint((QCon)i.Current);
				last = new AndIndexedLeaf(constraintWithJoins, node, last);
				_nodes.Add(last);
			}
		}
Example #28
0
			private IEnumerator FieldNames(FieldValue fieldValue)
			{
				Collection4 coll = new Collection4();
				IComparisonOperand curOp = fieldValue;
				while (curOp is FieldValue)
				{
					FieldValue curField = (FieldValue)curOp;
					coll.Prepend(curField.FieldName());
					curOp = curField.Parent();
				}
				return coll.GetEnumerator();
			}
Example #29
0
			public virtual IEnumerator Values()
			{
				Collection4 values = new Collection4();
				for (IEnumerator sIter = cache.GetEnumerator(); sIter.MoveNext(); )
				{
					string s = ((string)sIter.Current);
					values.Add(s);
				}
				return values.GetEnumerator();
			}
Example #30
0
		private void CollectLeaves(Collection4 leaves, Collection4 joins)
		{
			IEnumerator i = joins.GetEnumerator();
			while (i.MoveNext())
			{
				QConJoin join = ((QConJoin)i.Current);
				CollectLeavesFromJoin(leaves, join);
			}
		}
Example #31
0
 private ClassAspect AspectByName(Collection4 aspects, string aspectName)
 {
     var i = aspects.GetEnumerator();
     while (i.MoveNext())
     {
         var current = (ClassAspect) i.Current;
         if (current.GetName().Equals(aspectName))
         {
             return current;
         }
     }
     return null;
 }