public void Remove(string name) { Fx.Assert(!string.IsNullOrEmpty(name), "This should have been validated by the caller."); ExecutionProperty executionProperty = this.properties[name]; Fx.Assert(executionProperty != null, "This should only be called if we know the property exists"); if (executionProperty.Property is IExecutionProperty) { Fx.Assert(this.ownsThreadPropertiesList && this.threadProperties != null, "We should definitely be the list owner if we have an IExecutionProperty"); if (!this.threadProperties.Remove(executionProperty)) { Fx.Assert("We should have had this property in the list."); } } this.properties.Remove(name); if (executionProperty.Property is ExclusiveHandle) { this.exclusiveHandleCount--; UpdateChildExclusiveHandleCounts(-1); } if (this.lastPropertyName == name) { this.lastPropertyName = null; this.lastProperty = null; } }
public void Add(string name, object property, IdSpace visibility) { Fx.Assert(!string.IsNullOrEmpty(name), "The name should be validated before calling this collection."); Fx.Assert(property != null, "The property should be validated before caling this collection."); var executionProperty = new ExecutionProperty(name, property, visibility); this.properties.Add(name, executionProperty); if (this.lastPropertyName == name) { this.lastProperty = property; } if (property is ExclusiveHandle) { this.exclusiveHandleCount++; UpdateChildExclusiveHandleCounts(1); } if (property is IExecutionProperty) { AddIExecutionProperty(executionProperty, false); } }
public void CleanupWorkflowThread(ref Exception abortException) { if (this.threadProperties != null) { for (int i = this.threadProperties.Count - 1; i >= 0; i--) { ExecutionProperty property = this.threadProperties[i]; if (property.ShouldSkipNextCleanup) { property.ShouldSkipNextCleanup = false; } else { IExecutionProperty property2 = (IExecutionProperty)property.Property; try { property2.CleanupWorkflowThread(); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } abortException = exception; } } if (property.ShouldBeRemovedAfterCleanup) { this.threadProperties.RemoveAt(i); property.ShouldBeRemovedAfterCleanup = false; } } } }
private void AddIExecutionProperty(ExecutionProperty property, bool isDeserializationFixup) { bool flag = !isDeserializationFixup; if (this.threadProperties == null) { this.threadProperties = new List <ExecutionProperty>(1); this.ownsThreadPropertiesList = true; } else if (!this.ownsThreadPropertiesList) { List <ExecutionProperty> list = new List <ExecutionProperty>(this.threadProperties.Count); for (int i = 0; i < this.threadProperties.Count; i++) { ExecutionProperty item = this.threadProperties[i]; if (item.Name == property.Name) { if (flag) { item.ShouldBeRemovedAfterCleanup = true; list.Add(item); } } else { list.Add(item); } } this.threadProperties = list; this.ownsThreadPropertiesList = true; } else { for (int j = this.threadProperties.Count - 1; j >= 0; j--) { ExecutionProperty property3 = this.threadProperties[j]; if (property3.Name == property.Name) { if (flag) { property3.ShouldBeRemovedAfterCleanup = true; } else { this.threadProperties.RemoveAt(j); } break; } } } property.ShouldSkipNextCleanup = flag; this.threadProperties.Add(property); }
public void SetupWorkflowThread() { if (this.threadProperties != null) { for (int i = 0; i < this.threadProperties.Count; i++) { ExecutionProperty property = this.threadProperties[i]; property.ShouldSkipNextCleanup = false; ((IExecutionProperty)property.Property).SetupWorkflowThread(); } } }
public void SetupWorkflowThread() { if (_threadProperties != null) { for (int i = 0; i < _threadProperties.Count; i++) { ExecutionProperty executionProperty = _threadProperties[i]; executionProperty.ShouldSkipNextCleanup = false; IExecutionProperty property = (IExecutionProperty)executionProperty.Property; property.SetupWorkflowThread(); } } }
public void Add(string name, object property, IdSpace visibility) { ExecutionProperty property2 = new ExecutionProperty(name, property, visibility); this.properties.Add(name, property2); if (this.lastPropertyName == name) { this.lastProperty = property; } if (property is ExclusiveHandle) { this.exclusiveHandleCount++; this.UpdateChildExclusiveHandleCounts(1); } if (property is IExecutionProperty) { this.AddIExecutionProperty(property2, false); } }
public void Remove(string name) { ExecutionProperty item = this.properties[name]; if (item.Property is IExecutionProperty) { this.threadProperties.Remove(item); } this.properties.Remove(name); if (item.Property is ExclusiveHandle) { this.exclusiveHandleCount--; this.UpdateChildExclusiveHandleCounts(-1); } if (this.lastPropertyName == name) { this.lastPropertyName = null; this.lastProperty = null; } }
// This method only throws fatal exceptions public void CleanupWorkflowThread(ref Exception abortException) { if (_threadProperties != null) { for (int i = _threadProperties.Count - 1; i >= 0; i--) { ExecutionProperty current = _threadProperties[i]; if (current.ShouldSkipNextCleanup) { current.ShouldSkipNextCleanup = false; } else { IExecutionProperty property = (IExecutionProperty)current.Property; try { property.CleanupWorkflowThread(); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } abortException = e; } } if (current.ShouldBeRemovedAfterCleanup) { _threadProperties.RemoveAt(i); current.ShouldBeRemovedAfterCleanup = false; } } } }
private void AddIExecutionProperty(ExecutionProperty property, bool isDeserializationFixup) { var willCleanupBeCalled = !isDeserializationFixup; if (this.threadProperties == null) { this.threadProperties = new List <ExecutionProperty>(1); this.ownsThreadPropertiesList = true; } else if (!this.ownsThreadPropertiesList) { var updatedProperties = new List <ExecutionProperty>(this.threadProperties.Count); // We need to copy all properties to our new list and we // need to mark hidden properties as "to be removed" (or just // not copy them on the deserialization path) for (var i = 0; i < this.threadProperties.Count; i++) { var currentProperty = this.threadProperties[i]; if (currentProperty.Name == property.Name) { if (willCleanupBeCalled) { currentProperty.ShouldBeRemovedAfterCleanup = true; updatedProperties.Add(currentProperty); } // If cleanup won't be called then we are on the // deserialization path and shouldn't copy this // property over to our new list } else { updatedProperties.Add(currentProperty); } } this.threadProperties = updatedProperties; this.ownsThreadPropertiesList = true; } else { for (var i = this.threadProperties.Count - 1; i >= 0; i--) { var currentProperty = this.threadProperties[i]; if (currentProperty.Name == property.Name) { if (willCleanupBeCalled) { currentProperty.ShouldBeRemovedAfterCleanup = true; } else { this.threadProperties.RemoveAt(i); } // There will only be at most one property in this list that // matches the name break; } } } property.ShouldSkipNextCleanup = willCleanupBeCalled; this.threadProperties.Add(property); }