Exemplo n.º 1
0
            private void EnsureSingleOccurence(Transaction trans, IObjectInfoCollection col)
            {
                IEnumerator i = col.GetEnumerator();

                while (i.MoveNext())
                {
                    IObjectInfo objectInfo = (IObjectInfo)i.Current;
                    if (this.ReflectClass() != this._enclosing.ReflectorFor(trans, objectInfo.GetObject
                                                                                ()))
                    {
                        continue;
                    }
                    object obj        = this.ObjectFor(trans, objectInfo);
                    object fieldValue = this.FieldMetadata().GetOn(trans, obj);
                    if (fieldValue == null)
                    {
                        continue;
                    }
                    IBTreeRange range = this.FieldMetadata().Search(trans, fieldValue);
                    if (range.Size() > 1)
                    {
                        throw new UniqueFieldValueConstraintViolationException(this.ClassMetadata().GetName
                                                                                   (), this.FieldMetadata().GetName());
                    }
                }
            }
 private void AssertInfosAreConsistent(long[] ids, IObjectInfo[] infos)
 {
     for (int i = 0; i < infos.Length; i++)
     {
         IObjectInfo info = Db().GetObjectInfo(Db().GetByID(ids[i]));
         Assert.AreEqual(info.GetInternalID(), infos[i].GetInternalID());
         Assert.AreEqual(info.GetUUID().GetLongPart(), infos[i].GetUUID().GetLongPart());
         Assert.AreSame(info.GetObject(), infos[i].GetObject());
     }
 }
Exemplo n.º 3
0
            public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args)
            {
                if (oc.IsClosed())
                {
                    return;
                }
                IObjectInfoCollection updated = ((CommitEventArgs)args).Updated;
                IEnumerator           infos   = updated.GetEnumerator();

                while (infos.MoveNext())
                {
                    IObjectInfo info = (IObjectInfo)infos.Current;
                    object      obj  = info.GetObject();
                    oc.Refresh(obj, 2);
                }
            }
Exemplo n.º 4
0
 public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo
                                         )
 {
     return(TriggerCancellableObjectEventArgsInCallback(transaction, _deactivating, objectInfo
                                                        , objectInfo.GetObject()));
 }
Exemplo n.º 5
0
		private void ObjectOnDelete(Transaction transaction, ClassMetadata yc, IObjectInfo
			 reference)
		{
			Callbacks().ObjectOnDelete(transaction, reference);
			yc.DispatchEvent(transaction, reference.GetObject(), EventDispatchers.Delete);
		}
Exemplo n.º 6
0
		private bool ObjectCanDelete(Transaction transaction, ClassMetadata yc, IObjectInfo
			 objectInfo)
		{
			return Callbacks().ObjectCanDelete(transaction, objectInfo) && yc.DispatchEvent(transaction
				, objectInfo.GetObject(), EventDispatchers.CanDelete);
		}
Exemplo n.º 7
0
 private bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo)
 {
     var container = transaction.Container();
     return container.Callbacks().ObjectCanDeactivate(transaction, objectInfo) && DispatchEvent
         (transaction, objectInfo.GetObject(), EventDispatchers.CanDeactivate);
 }
Exemplo n.º 8
0
 private void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj)
 {
     var container = transaction.Container();
     container.Callbacks().ObjectOnDeactivate(transaction, obj);
     DispatchEvent(transaction, obj.GetObject(), EventDispatchers.Deactivate);
 }
Exemplo n.º 9
0
 public virtual void Deactivate(Transaction trans, IObjectInfo reference, IActivationDepth
     depth)
 {
     var obj = reference.GetObject();
     if (ObjectCanDeactivate(trans, reference))
     {
         ForceDeactivation(trans, depth, obj);
         ObjectOnDeactivate(trans, reference);
     }
 }
Exemplo n.º 10
0
		public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo
			)
		{
			return TriggerCancellableObjectEventArgsInCallback(transaction, _deactivating, objectInfo
				, objectInfo.GetObject());
		}