public override bool Equals(object obj) { ActivityExecutorDelegateInfo <T> info = obj as ActivityExecutorDelegateInfo <T>; if (info == null) { return(false); } return((((((info.delegateValue == null) && (this.delegateValue == null)) || ((info.delegateValue != null) && info.delegateValue.Equals(this.delegateValue))) && (((info.eventListener == null) && (this.eventListener == null)) || ((info.eventListener != null) && info.eventListener.Equals(this.eventListener)))) && ((info.activityQualifiedName == this.activityQualifiedName) && (info.contextId == this.contextId))) && (info.wantInTransact == this.wantInTransact)); }
public override bool Equals(object obj) { ActivityExecutorDelegateInfo <T> otherObject = obj as ActivityExecutorDelegateInfo <T>; if (otherObject == null) { return(false); } return(( (otherObject.delegateValue == null && this.delegateValue == null) || (otherObject.delegateValue != null && otherObject.delegateValue.Equals(this.delegateValue)) ) && ( (otherObject.eventListener == null && this.eventListener == null) || (otherObject.eventListener != null && otherObject.eventListener.Equals(this.eventListener)) ) && otherObject.activityQualifiedName == this.activityQualifiedName && otherObject.contextId == this.contextId && otherObject.wantInTransact == this.wantInTransact); }
internal void ReleaseLocks(bool transactional) { if (this.currentActivity == null) { throw new ObjectDisposedException("ActivityExecutionContext"); } // remove the callback. this.Activity.RemoveProperty(LockAcquiredCallbackProperty); // The assumption is that lock contentions will be few. Hence, we optimize serialization // size over performance, for ex. do not persist the list of locks that have already been // granted. ICollection <string> handles = GetAllSynchronizationHandles(this.Activity); if (handles == null || handles.Count == 0) { return; } List <Activity> waitingActivities = new List <Activity>(); Activity parent = Activity.Parent; while (parent != null) { if (parent.SupportsSynchronization || parent.Parent == null) { Dictionary <string, GrantedLock> grantedLocks = (Dictionary <string, GrantedLock>)parent.GetValue(GrantedLocksProperty); // if its an transactional release of locks, then release it and then keep it // cached, so that in case of rollback, we can reacuire locks if (transactional) { Dictionary <string, GrantedLock> cachedGrantedLocks = new Dictionary <string, GrantedLock>(); if (grantedLocks != null) { foreach (KeyValuePair <string, GrantedLock> grantedLockEntry in grantedLocks) { cachedGrantedLocks.Add(grantedLockEntry.Key, (GrantedLock)grantedLockEntry.Value.Clone()); } } parent.SetValue(CachedGrantedLocksProperty, cachedGrantedLocks); } if (grantedLocks != null) { foreach (string handle in handles) { if (!grantedLocks.ContainsKey(handle)) { continue; } else if (grantedLocks[handle].WaitList.Count == 0) { grantedLocks.Remove(handle); } else if (grantedLocks[handle].Holder != this.Activity) { grantedLocks[handle].WaitList.Remove(this.Activity); } else { // Grant the lock to the next waiting activity. Activity waitingActivity = grantedLocks[handle].WaitList[0]; grantedLocks[handle].WaitList.RemoveAt(0); grantedLocks[handle].Holder = waitingActivity; if (!waitingActivities.Contains(waitingActivity)) { waitingActivities.Add(waitingActivity); } } } if (grantedLocks.Count == 0) { parent.RemoveProperty(GrantedLocksProperty); } } } // If we reach a parent which has at least one handle, then we do not need to // go any further as the parent would already have acquired all our locks for // itself. Note that we still need to acquire our locks in the same parent if // the parent ProvidesSychronization, hence, this if check is *not* after // "parent = parent.Parent"! ICollection <string> synchronizationHandlesOnParent = (ICollection <string>)parent.GetValue(Activity.SynchronizationHandlesProperty); if (synchronizationHandlesOnParent != null && synchronizationHandlesOnParent.Count != 0) { break; } parent = parent.Parent; } // Try and acquire locks for all the waiting activities. foreach (Activity waitingActivity in waitingActivities) { if (AcquireLocks(waitingActivity)) { ActivityExecutorDelegateInfo <EventArgs> waitingActivityCallback = (ActivityExecutorDelegateInfo <EventArgs>)waitingActivity.GetValue(LockAcquiredCallbackProperty); waitingActivityCallback.InvokeDelegate(this.Activity.ContextActivity, EventArgs.Empty, false, transactional); } } }