public BatchToken BeginSave() { BatchToken token = new BatchToken(); _BatchSavedDataObjects.Add(token, new List <T>()); return(token); }
public void EndSave(BatchToken token) { this.OnBatchSaved(token); // this causes a single BatchSaved event to be fired if (!_BatchSavedDataObjects.Remove(token)) { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } }
int _SavedObjectThreshold = 20; // if the number of objects being stored for a batch reaches this threshold, then those objects are to be cleared from the list. public BatchToken BeginSave() { // create a batch token to represent this batch BatchToken token = new BatchToken(); lock (_BatchSavedDataObjectsLock) { _BatchSavedDataObjects.Add(token, new List <T>()); } return(token); }
public void Save(BatchToken token, T dataObject) { List <T> batchSavedDataObjects; if (_BatchSavedDataObjects.TryGetValue(token, out batchSavedDataObjects)) { // perform save logic batchSavedDataObjects.Add(dataObject); } else { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } }
protected void OnBatchSaved(BatchToken token) { if (this.BatchSaved != null) { List <T> batchSavedDataObjects; if (_BatchSavedDataObjects.TryGetValue(token, out batchSavedDataObjects)) { this.BatchSaved(this, new BatchDataObjectEventArgs <T>(batchSavedDataObjects)); } else { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } } }
int _SavedObjectThreshold = 17; // if the number of objects being stored for a batch reaches this threshold, then those objects are to be cleared from the list. public BatchToken BeginSave() { // create a batch token to represent this batch BatchToken token = new BatchToken(); _BatchSavedDataObjectsLock.EnterWriteLock(); try { _BatchSavedDataObjects.Add(token, new List <T>()); } finally { _BatchSavedDataObjectsLock.ExitWriteLock(); } return(token); }
public void Save(BatchToken token, T dataObject) { List <T> batchSavedDataObjects; lock (_BatchSavedDataObjectsLock) { if (!_BatchSavedDataObjects.TryGetValue(token, out batchSavedDataObjects)) { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } } // perform save logic // add the data object to the list storing the data objects that have been saved for this batch lock (batchSavedDataObjects) { batchSavedDataObjects.Add(dataObject); this.OnBatchSaved(batchSavedDataObjects); } }
public void Save(BatchToken token, T dataObject) { List <T> batchSavedDataObjects; // the read lock prevents EndSave from executing before this Save method has a chance to finish executing _BatchSavedDataObjectsLock.EnterReadLock(); try { if (!_BatchSavedDataObjects.TryGetValue(token, out batchSavedDataObjects)) { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } // perform save logic this.OnBatchSaved(batchSavedDataObjects, dataObject); } finally { _BatchSavedDataObjectsLock.ExitReadLock(); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is V1ListPaymentsRequest other && ((Order == null && other.Order == null) || (Order?.Equals(other.Order) == true)) && ((BeginTime == null && other.BeginTime == null) || (BeginTime?.Equals(other.BeginTime) == true)) && ((EndTime == null && other.EndTime == null) || (EndTime?.Equals(other.EndTime) == true)) && ((Limit == null && other.Limit == null) || (Limit?.Equals(other.Limit) == true)) && ((BatchToken == null && other.BatchToken == null) || (BatchToken?.Equals(other.BatchToken) == true)) && ((IncludePartial == null && other.IncludePartial == null) || (IncludePartial?.Equals(other.IncludePartial) == true))); }
public void EndSave(BatchToken token) { List <T> batchSavedDataObjects; _BatchSavedDataObjectsLock.EnterWriteLock(); try { if (!_BatchSavedDataObjects.TryGetValue(token, out batchSavedDataObjects)) { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } this.OnBatchSaved(batchSavedDataObjects); // this causes a single BatchSaved event to be fired if (!_BatchSavedDataObjects.Remove(token)) { throw new ArgumentException("The BatchToken is expired or invalid.", "token"); } } finally { _BatchSavedDataObjectsLock.ExitWriteLock(); } }
public override int GetHashCode() { int hashCode = 358877715; if (Order != null) { hashCode += Order.GetHashCode(); } if (BeginTime != null) { hashCode += BeginTime.GetHashCode(); } if (EndTime != null) { hashCode += EndTime.GetHashCode(); } if (Limit != null) { hashCode += Limit.GetHashCode(); } if (BatchToken != null) { hashCode += BatchToken.GetHashCode(); } if (IncludePartial != null) { hashCode += IncludePartial.GetHashCode(); } return(hashCode); }
/// <summary> /// Indicates if this token contains the same values as the given one. /// </summary> public bool Equals(BatchToken other) { return(BatchID == other.BatchID && VertexID == other.VertexID && IndexID == other.IndexID); }
/// <summary> /// Copies the properties from the given token to this instance. /// </summary> public void CopyFrom(BatchToken token) { BatchID = token.BatchID; VertexID = token.VertexID; IndexID = token.IndexID; }
public override void Render(Painter painter) { int numChildren = _children.Count; uint frameId = painter.FrameId; bool cacheEnabled = frameId != 0; bool selfOrParentChanged = _lastParentOrSelfChangeFrameID == frameId; for (int i = 0; i < numChildren; ++i) { DisplayObject child = _children[i]; if (child._hasVisibleArea) { if (selfOrParentChanged) { child._lastParentOrSelfChangeFrameID = frameId; } if (child._lastParentOrSelfChangeFrameID != frameId && child._lastChildChangeFrameID != frameId && child._tokenFrameID == frameId - 1 && cacheEnabled) { painter.PushState(SCacheToken); painter.DrawFromCache(child._pushToken, child._popToken); painter.PopState(child._popToken); child._pushToken.CopyFrom(SCacheToken); } else { BatchToken pushToken = cacheEnabled ? child._pushToken : null; BatchToken popToken = cacheEnabled ? child._popToken : null; FragmentFilter filter = child._filter; DisplayObject mask = child._mask; painter.PushState(pushToken); painter.SetStateTo(child.TransformationMatrix, child.Alpha, child.BlendMode); if (mask != null) { painter.DrawMask(mask, child); } if (filter != null) { filter.Render(painter); } else { child.Render(painter); } if (mask != null) { painter.EraseMask(mask, child); } painter.PopState(popToken); } if (cacheEnabled) { child._tokenFrameID = frameId; } } } }