Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / Workflow / Activities / Design / ServiceOperationUIEditor.cs / 1305376 / ServiceOperationUIEditor.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.Workflow.Activities.Design
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.Design;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Diagnostics;
using System.ServiceModel;
using System.Windows.Forms;
internal class ServiceOperationUIEditor : UITypeEditor
{
public static bool TryPickOperation(IServiceProvider serviceProvider, Activity activity, OperationInfoBase currentOperation, out OperationInfoBase selectedOperation)
{
selectedOperation = null;
bool isReceiveActivity = activity is ReceiveActivity;
try
{
using (OperationPickerDialog operationPicker = new OperationPickerDialog(serviceProvider, isReceiveActivity))
{
Walker activityTreeWalker = new Walker();
Type allowedActivityType = null;
if (isReceiveActivity)
{
allowedActivityType = typeof(ReceiveActivity);
}
else
{
allowedActivityType = typeof(SendActivity);
}
activityTreeWalker.FoundActivity += delegate(Walker walker, WalkerEventArgs eventArgs)
{
Activity foundActivity = eventArgs.CurrentActivity;
if (!(allowedActivityType.IsAssignableFrom(foundActivity.GetType())))
{
return;
}
if (!foundActivity.Enabled)
{
return;
}
if (foundActivity is ReceiveActivity)
{
ReceiveActivity reciveActivity = foundActivity as ReceiveActivity;
if (reciveActivity.ServiceOperationInfo != null)
{
operationPicker.AddServiceOperation(reciveActivity.ServiceOperationInfo, reciveActivity);
}
}
if (foundActivity is SendActivity)
{
SendActivity sendActivity = foundActivity as SendActivity;
if (sendActivity.ServiceOperationInfo != null)
{
operationPicker.AddServiceOperation(sendActivity.ServiceOperationInfo, sendActivity);
}
}
};
activityTreeWalker.Walk(activity.RootActivity);
OperationInfoBase currentServiceOperationInfo = currentOperation as OperationInfoBase;
if (currentServiceOperationInfo != null)
{
operationPicker.SelectedOperation = currentServiceOperationInfo;
}
DialogResult dialogResult = operationPicker.ShowDialog();
if ((operationPicker.SelectedOperation != null) && (dialogResult == DialogResult.OK) && !operationPicker.SelectedOperation.Equals(currentServiceOperationInfo))
{
selectedOperation = operationPicker.SelectedOperation.Clone();
return true;
}
}
}
catch (Exception e)
{
DesignerHelpers.ShowMessage(serviceProvider, e.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
throw;
}
return false;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if (provider == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("provider");
}
OperationInfoBase pickedServiceOperation = null;
if (TryPickOperation(provider, (Activity) context.Instance, (OperationInfoBase) value, out pickedServiceOperation))
{
return pickedServiceOperation;
}
else
{
return base.EditValue(context, provider, value);
}
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlForm.cs
- KernelTypeValidation.cs
- CustomAttributeBuilder.cs
- DetailsViewPageEventArgs.cs
- SamlSubject.cs
- EdmTypeAttribute.cs
- DynamicQueryableWrapper.cs
- HttpBufferlessInputStream.cs
- ConsumerConnectionPoint.cs
- ProfileSettingsCollection.cs
- Claim.cs
- SecurityTokenProvider.cs
- QueueProcessor.cs
- ReachVisualSerializer.cs
- NotifyParentPropertyAttribute.cs
- RowUpdatingEventArgs.cs
- WeakRefEnumerator.cs
- HtmlTableRowCollection.cs
- TargetParameterCountException.cs
- AliasedSlot.cs
- NameNode.cs
- CLSCompliantAttribute.cs
- RoutedEventConverter.cs
- ToolStripSettings.cs
- ImmutableObjectAttribute.cs
- TextStore.cs
- RemotingHelper.cs
- OutputWindow.cs
- Rect.cs
- CurrentChangingEventManager.cs
- Point3DCollection.cs
- _ListenerRequestStream.cs
- StringInfo.cs
- xmlfixedPageInfo.cs
- ToolStripSeparator.cs
- AddInControllerImpl.cs
- DecoderFallback.cs
- XmlSerializerAssemblyAttribute.cs
- Page.cs
- CachedPathData.cs
- HttpCacheVary.cs
- __FastResourceComparer.cs
- remotingproxy.cs
- ExceptionValidationRule.cs
- TransformPattern.cs
- AsyncCompletedEventArgs.cs
- BindingManagerDataErrorEventArgs.cs
- DnsEndPoint.cs
- AnimatedTypeHelpers.cs
- SecurityDocument.cs
- EdmComplexPropertyAttribute.cs
- MaskInputRejectedEventArgs.cs
- RoleService.cs
- DataBindEngine.cs
- DesignerWithHeader.cs
- wmiprovider.cs
- DomainConstraint.cs
- CngKey.cs
- LinqDataSourceHelper.cs
- WebServiceTypeData.cs
- JoinTreeNode.cs
- ExtendedPropertyDescriptor.cs
- WindowsAltTab.cs
- HtmlButton.cs
- ListSortDescriptionCollection.cs
- SvcMapFileLoader.cs
- HwndMouseInputProvider.cs
- Adorner.cs
- SymmetricAlgorithm.cs
- DataControlFieldHeaderCell.cs
- NotifyCollectionChangedEventArgs.cs
- WindowInteropHelper.cs
- FormatterServicesNoSerializableCheck.cs
- TraceSection.cs
- VSWCFServiceContractGenerator.cs
- HelpKeywordAttribute.cs
- HtmlTextArea.cs
- TreeWalkHelper.cs
- SmtpSection.cs
- Transform3D.cs
- TextTabProperties.cs
- DBBindings.cs
- MetadataCache.cs
- NamespaceCollection.cs
- EntityDataSourceStatementEditor.cs
- AppDomainFactory.cs
- CustomTypeDescriptor.cs
- ReturnType.cs
- WebConfigurationFileMap.cs
- DynamicRendererThreadManager.cs
- VerificationAttribute.cs
- QilPatternFactory.cs
- SerialReceived.cs
- TdsParserStaticMethods.cs
- SafeNativeMethods.cs
- ModelPropertyCollectionImpl.cs
- ImportRequest.cs
- OrderedDictionary.cs
- StringAnimationUsingKeyFrames.cs
- Point3DCollection.cs