Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Rules / RuleSetCollection.cs / 1305376 / RuleSetCollection.cs
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Text; using System.Workflow.ComponentModel; namespace System.Workflow.Activities.Rules { #region class RuleSetCollection public sealed class RuleSetCollection : KeyedCollection, IWorkflowChangeDiff { #region members and constructors private bool _runtimeInitialized; [NonSerialized] private object syncLock = new object(); public RuleSetCollection() { } #endregion #region keyed collection members protected override string GetKeyForItem(RuleSet item) { return item.Name; } protected override void InsertItem(int index, RuleSet item) { if (this._runtimeInitialized) throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime)); if (item.Name != null && item.Name.Length >= 0 && this.Contains(item.Name)) { string message = string.Format(CultureInfo.CurrentCulture, Messages.RuleSetExists, item.Name); throw new ArgumentException(message); } base.InsertItem(index, item); } protected override void RemoveItem(int index) { if (this._runtimeInitialized) throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime)); base.RemoveItem(index); } protected override void SetItem(int index, RuleSet item) { if (this._runtimeInitialized) throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime)); base.SetItem(index, item); } new public void Add(RuleSet item) { if (this._runtimeInitialized) throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime)); if (null == item) { throw new ArgumentNullException("item"); } if (null == item.Name) { string message = string.Format(CultureInfo.CurrentCulture, Messages.InvalidRuleSetName, "item.Name"); throw new ArgumentException(message); } base.Add(item); } #endregion #region runtime initializing internal void OnRuntimeInitialized() { lock (this.syncLock) { if (this._runtimeInitialized) return; foreach (RuleSet ruleSet in this) { ruleSet.OnRuntimeInitialized(); } _runtimeInitialized = true; } } internal bool RuntimeMode { set { this._runtimeInitialized = value; } get { return this._runtimeInitialized; } } internal string GenerateRuleSetName() { string nameBase = Messages.NewRuleSetName; string newName; int i = 1; do { newName = nameBase + i.ToString(CultureInfo.InvariantCulture); i++; } while(this.Contains(newName)); return newName; } #endregion #region IWorkflowChangeDiff Members public IList Diff(object originalDefinition, object changedDefinition) { List listChanges = new List (); RuleSetCollection originalRuleSets = (RuleSetCollection)originalDefinition; RuleSetCollection changedRuleSets = (RuleSetCollection)changedDefinition; if (null != changedRuleSets) { foreach (RuleSet changedRuleSet in changedRuleSets) { if ((originalRuleSets != null) && (originalRuleSets.Contains(changedRuleSet.Name))) { RuleSet originalRuleSet = originalRuleSets[changedRuleSet.Name]; if (!originalRuleSet.Equals(changedRuleSet)) { listChanges.Add(new UpdatedRuleSetAction(originalRuleSet, changedRuleSet)); } } else { listChanges.Add(new AddedRuleSetAction(changedRuleSet)); } } } if (null != originalRuleSets) { foreach (RuleSet originalRuleSet in originalRuleSets) { if ((changedRuleSets == null) || (!changedRuleSets.Contains(originalRuleSet.Name))) { listChanges.Add(new RemovedRuleSetAction(originalRuleSet)); } } } return listChanges; } #endregion } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InfoCardCryptoHelper.cs
- XmlEnumAttribute.cs
- TemplateKeyConverter.cs
- ValidationSummary.cs
- NamespaceCollection.cs
- categoryentry.cs
- HttpStaticObjectsCollectionWrapper.cs
- MethodBuilder.cs
- ListView.cs
- CodeBinaryOperatorExpression.cs
- HuffmanTree.cs
- ActivationWorker.cs
- CollectionBuilder.cs
- Color.cs
- PrintDialogException.cs
- ObjectNavigationPropertyMapping.cs
- XmlSchemaDocumentation.cs
- ValueChangedEventManager.cs
- BulletDecorator.cs
- ProtocolsConfigurationHandler.cs
- SchemaMerger.cs
- ContainsRowNumberChecker.cs
- TempEnvironment.cs
- TdsParserHelperClasses.cs
- TreeNodeBindingCollection.cs
- DefaultClaimSet.cs
- BrowserTree.cs
- ImportDesigner.xaml.cs
- ServicePointManager.cs
- SubpageParagraph.cs
- DataGridSortCommandEventArgs.cs
- X509RecipientCertificateClientElement.cs
- ModifierKeysValueSerializer.cs
- ParenthesizePropertyNameAttribute.cs
- XmlResolver.cs
- HttpRequestContext.cs
- SystemIPv4InterfaceProperties.cs
- FileCodeGroup.cs
- GeometryCombineModeValidation.cs
- WebControlAdapter.cs
- ZipIOExtraField.cs
- EntityTypeEmitter.cs
- KeyFrames.cs
- TdsParser.cs
- QilScopedVisitor.cs
- IndexOutOfRangeException.cs
- GiveFeedbackEvent.cs
- WindowsRegion.cs
- AttributeProviderAttribute.cs
- BooleanProjectedSlot.cs
- Hyperlink.cs
- ToolConsole.cs
- ToolboxComponentsCreatingEventArgs.cs
- wmiprovider.cs
- PageThemeCodeDomTreeGenerator.cs
- SoapHeaderException.cs
- ColorConverter.cs
- WebPartDesigner.cs
- JsonDataContract.cs
- BaseCodeDomTreeGenerator.cs
- PixelShader.cs
- AdRotator.cs
- FolderBrowserDialog.cs
- ProxyDataContractResolver.cs
- InternalConfigSettingsFactory.cs
- OdbcFactory.cs
- PreviewControlDesigner.cs
- _KerberosClient.cs
- DockingAttribute.cs
- GradientStop.cs
- UnsafeNativeMethods.cs
- SqlConnectionManager.cs
- NamespaceCollection.cs
- UdpConstants.cs
- Module.cs
- BitStack.cs
- RequestCachePolicyConverter.cs
- UnknownWrapper.cs
- RelationshipConstraintValidator.cs
- TabControl.cs
- OptimisticConcurrencyException.cs
- EntityTransaction.cs
- _NetworkingPerfCounters.cs
- Operand.cs
- CultureSpecificStringDictionary.cs
- Margins.cs
- StandardOleMarshalObject.cs
- OneOfTypeConst.cs
- COM2PropertyPageUITypeConverter.cs
- WebPartsPersonalizationAuthorization.cs
- Timeline.cs
- AutomationFocusChangedEventArgs.cs
- ApplicationDirectoryMembershipCondition.cs
- EpmTargetTree.cs
- SimpleRecyclingCache.cs
- XmlUrlEditor.cs
- DataSet.cs
- AttachedPropertyBrowsableAttribute.cs
- NumericExpr.cs
- TextModifier.cs