Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Behaviors / SynchronizationScope.cs / 1305376 / SynchronizationScope.cs
namespace System.Workflow.ComponentModel
{
#region Imports
using System;
using System.Globalization;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel.Compiler;
#endregion
[SRDescription(SR.SynchronizationScopeActivityDescription)]
[ToolboxItem(typeof(ActivityToolboxItem))]
[ToolboxBitmap(typeof(SynchronizationScopeActivity), "Resources.Sequence.png")]
[SupportsSynchronization]
[Designer(typeof(SequenceDesigner), typeof(IDesigner))]
public sealed class SynchronizationScopeActivity : CompositeActivity, IActivityEventListener
{
public SynchronizationScopeActivity()
{
}
public SynchronizationScopeActivity(string name)
:base(name)
{
}
[SRDisplayName(SR.SynchronizationHandles)]
[SRDescription(SR.SynchronizationHandlesDesc)]
[TypeConverter(typeof(SynchronizationHandlesTypeConverter))]
[EditorAttribute(typeof(SynchronizationHandlesEditor), typeof(System.Drawing.Design.UITypeEditor))]
public ICollection SynchronizationHandles
{
get
{
return this.GetValue(SynchronizationHandlesProperty) as ICollection;
}
set
{
this.SetValue(SynchronizationHandlesProperty, value);
}
}
protected internal override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
return SequenceHelper.Execute(this, executionContext);
}
protected internal override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext)
{
return SequenceHelper.Cancel(this, executionContext);
}
void IActivityEventListener.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)
{
SequenceHelper.OnEvent(this, sender, e);
}
protected internal override void OnActivityChangeRemove(ActivityExecutionContext executionContext, Activity removedActivity)
{
SequenceHelper.OnActivityChangeRemove(this, executionContext, removedActivity);
}
protected internal override void OnWorkflowChangesCompleted(ActivityExecutionContext executionContext)
{
SequenceHelper.OnWorkflowChangesCompleted(this, executionContext);
}
}
#region Class SynchronizationHandlesTypeConverter
internal sealed class SynchronizationHandlesTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string) && value is ICollection)
return Stringify(value as ICollection);
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
return UnStringify(value as string);
return base.ConvertFrom(context, culture, value);
}
internal static string Stringify(ICollection synchronizationHandles)
{
string stringifiedValue = string.Empty;
if (synchronizationHandles == null)
return stringifiedValue;
foreach (string handle in synchronizationHandles)
{
if (handle == null)
continue;
if (stringifiedValue != string.Empty)
stringifiedValue += ", ";
stringifiedValue += handle.Replace(",", "\\,");
}
return stringifiedValue;
}
internal static ICollection UnStringify(string stringifiedValue)
{
ICollection synchronizationHandles = new List();
stringifiedValue = stringifiedValue.Replace("\\,", ">");
foreach (string handle in stringifiedValue.Split(new char[] { ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
string realHandle = handle.Trim().Replace('>', ',');
if (realHandle != string.Empty && !synchronizationHandles.Contains(realHandle))
synchronizationHandles.Add(realHandle);
}
return synchronizationHandles;
}
}
#endregion
internal sealed class SynchronizationHandlesEditor : UITypeEditor
{
private MultilineStringEditor stringEditor = new MultilineStringEditor();
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
string stringValue = SynchronizationHandlesTypeConverter.Stringify(value as ICollection);
stringValue = stringEditor.EditValue(context, provider, stringValue) as string;
value = SynchronizationHandlesTypeConverter.UnStringify(stringValue);
return value;
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return stringEditor.GetEditStyle(context);
}
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return stringEditor.GetPaintValueSupported(context);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
namespace System.Workflow.ComponentModel
{
#region Imports
using System;
using System.Globalization;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel.Compiler;
#endregion
[SRDescription(SR.SynchronizationScopeActivityDescription)]
[ToolboxItem(typeof(ActivityToolboxItem))]
[ToolboxBitmap(typeof(SynchronizationScopeActivity), "Resources.Sequence.png")]
[SupportsSynchronization]
[Designer(typeof(SequenceDesigner), typeof(IDesigner))]
public sealed class SynchronizationScopeActivity : CompositeActivity, IActivityEventListener
{
public SynchronizationScopeActivity()
{
}
public SynchronizationScopeActivity(string name)
:base(name)
{
}
[SRDisplayName(SR.SynchronizationHandles)]
[SRDescription(SR.SynchronizationHandlesDesc)]
[TypeConverter(typeof(SynchronizationHandlesTypeConverter))]
[EditorAttribute(typeof(SynchronizationHandlesEditor), typeof(System.Drawing.Design.UITypeEditor))]
public ICollection SynchronizationHandles
{
get
{
return this.GetValue(SynchronizationHandlesProperty) as ICollection;
}
set
{
this.SetValue(SynchronizationHandlesProperty, value);
}
}
protected internal override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
return SequenceHelper.Execute(this, executionContext);
}
protected internal override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext)
{
return SequenceHelper.Cancel(this, executionContext);
}
void IActivityEventListener.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)
{
SequenceHelper.OnEvent(this, sender, e);
}
protected internal override void OnActivityChangeRemove(ActivityExecutionContext executionContext, Activity removedActivity)
{
SequenceHelper.OnActivityChangeRemove(this, executionContext, removedActivity);
}
protected internal override void OnWorkflowChangesCompleted(ActivityExecutionContext executionContext)
{
SequenceHelper.OnWorkflowChangesCompleted(this, executionContext);
}
}
#region Class SynchronizationHandlesTypeConverter
internal sealed class SynchronizationHandlesTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string) && value is ICollection)
return Stringify(value as ICollection);
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
return UnStringify(value as string);
return base.ConvertFrom(context, culture, value);
}
internal static string Stringify(ICollection synchronizationHandles)
{
string stringifiedValue = string.Empty;
if (synchronizationHandles == null)
return stringifiedValue;
foreach (string handle in synchronizationHandles)
{
if (handle == null)
continue;
if (stringifiedValue != string.Empty)
stringifiedValue += ", ";
stringifiedValue += handle.Replace(",", "\\,");
}
return stringifiedValue;
}
internal static ICollection UnStringify(string stringifiedValue)
{
ICollection synchronizationHandles = new List();
stringifiedValue = stringifiedValue.Replace("\\,", ">");
foreach (string handle in stringifiedValue.Split(new char[] { ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
string realHandle = handle.Trim().Replace('>', ',');
if (realHandle != string.Empty && !synchronizationHandles.Contains(realHandle))
synchronizationHandles.Add(realHandle);
}
return synchronizationHandles;
}
}
#endregion
internal sealed class SynchronizationHandlesEditor : UITypeEditor
{
private MultilineStringEditor stringEditor = new MultilineStringEditor();
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
string stringValue = SynchronizationHandlesTypeConverter.Stringify(value as ICollection);
stringValue = stringEditor.EditValue(context, provider, stringValue) as string;
value = SynchronizationHandlesTypeConverter.UnStringify(stringValue);
return value;
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return stringEditor.GetEditStyle(context);
}
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return stringEditor.GetPaintValueSupported(context);
}
}
}
// 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
- EditorPartDesigner.cs
- MappingModelBuildProvider.cs
- TransactionFlowAttribute.cs
- HitTestResult.cs
- EnvelopedSignatureTransform.cs
- XsdCachingReader.cs
- IsolatedStorageException.cs
- XslAst.cs
- IPEndPoint.cs
- ExtensionFile.cs
- FocusChangedEventArgs.cs
- XmlEncApr2001.cs
- Accessible.cs
- TreeWalkHelper.cs
- SQLBinary.cs
- BitVector32.cs
- Deserializer.cs
- BevelBitmapEffect.cs
- ListView.cs
- UserControlParser.cs
- InputBinder.cs
- EdmComplexPropertyAttribute.cs
- ConversionContext.cs
- Vector3DConverter.cs
- WebPartDeleteVerb.cs
- CodeDOMUtility.cs
- TableRow.cs
- AffineTransform3D.cs
- WindowsListViewItemStartMenu.cs
- DictionaryEditChange.cs
- EntityContainer.cs
- SingleSelectRootGridEntry.cs
- Error.cs
- Mapping.cs
- TemplateAction.cs
- QuadraticBezierSegment.cs
- TimelineGroup.cs
- COM2ColorConverter.cs
- ArgumentOutOfRangeException.cs
- ToolboxItemFilterAttribute.cs
- EventListener.cs
- FixedSOMPageElement.cs
- CornerRadiusConverter.cs
- HostingEnvironmentWrapper.cs
- OleDbConnectionInternal.cs
- PartialArray.cs
- CookieParameter.cs
- DataGridTablesFactory.cs
- SpanIndex.cs
- ToolboxComponentsCreatedEventArgs.cs
- WindowsIPAddress.cs
- NativeWindow.cs
- DbInsertCommandTree.cs
- TemplatedWizardStep.cs
- PageCatalogPart.cs
- EdmItemCollection.cs
- ParameterModifier.cs
- PageContentAsyncResult.cs
- RSAPKCS1SignatureDeformatter.cs
- AmbientProperties.cs
- XmlConvert.cs
- SafeCryptContextHandle.cs
- SchemaCompiler.cs
- StopStoryboard.cs
- LinkedResourceCollection.cs
- FileSystemWatcher.cs
- VirtualDirectoryMappingCollection.cs
- InputScope.cs
- QilStrConcat.cs
- ComponentSerializationService.cs
- messageonlyhwndwrapper.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- sqlstateclientmanager.cs
- DataGridViewBindingCompleteEventArgs.cs
- ToolStripScrollButton.cs
- RemotingSurrogateSelector.cs
- XmlNodeChangedEventArgs.cs
- NotFiniteNumberException.cs
- SchemaTableColumn.cs
- __Error.cs
- WebPartMovingEventArgs.cs
- ResourceAttributes.cs
- linebase.cs
- SpecialFolderEnumConverter.cs
- Knowncolors.cs
- MbpInfo.cs
- ResourceReferenceExpression.cs
- SingleBodyParameterMessageFormatter.cs
- FixedSOMContainer.cs
- IImplicitResourceProvider.cs
- HttpListenerRequest.cs
- XmlILAnnotation.cs
- StyleHelper.cs
- BrowserTree.cs
- PingReply.cs
- SqlFactory.cs
- AspNetHostingPermission.cs
- HyperLinkColumn.cs
- FixedHighlight.cs
- ParentUndoUnit.cs