You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,289 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
[DesignerSerializer(typeof(DependencyObjectCodeDomSerializer), typeof(CodeDomSerializer))]
|
||||
[TypeConverter(typeof(ChannelTokenTypeConverter))]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ChannelToken : DependencyObject, IPropertyValueProvider
|
||||
{
|
||||
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
|
||||
internal static readonly DependencyProperty EndpointNameProperty =
|
||||
DependencyProperty.Register("EndpointName",
|
||||
typeof(string),
|
||||
typeof(ChannelToken),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
|
||||
internal static readonly DependencyProperty NameProperty =
|
||||
DependencyProperty.Register("Name",
|
||||
typeof(string),
|
||||
typeof(ChannelToken),
|
||||
new PropertyMetadata(null, DependencyPropertyOptions.Metadata,
|
||||
new Attribute[] { new BrowsableAttribute(false) }));
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
|
||||
internal static readonly DependencyProperty OwnerActivityNameProperty =
|
||||
DependencyProperty.Register("OwnerActivityName",
|
||||
typeof(string),
|
||||
typeof(ChannelToken),
|
||||
new PropertyMetadata(null, DependencyPropertyOptions.Metadata,
|
||||
new Attribute[] { new TypeConverterAttribute(typeof(PropertyValueProviderTypeConverter)) }));
|
||||
|
||||
public ChannelToken()
|
||||
{
|
||||
}
|
||||
|
||||
internal ChannelToken(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[SR2Description(SR2DescriptionAttribute.ChannelToken_EndpointName_Description)]
|
||||
public string EndpointName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(EndpointNameProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(EndpointNameProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(null)]
|
||||
[SR2Description(SR2DescriptionAttribute.ChannelToken_Name_Description)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(NameProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(NameProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[TypeConverter(typeof(PropertyValueProviderTypeConverter))]
|
||||
[SR2Description(SR2DescriptionAttribute.ChannelToken_OwnerActivityName_Description)]
|
||||
public string OwnerActivityName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(OwnerActivityNameProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(OwnerActivityNameProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
ICollection IPropertyValueProvider.GetPropertyValues(ITypeDescriptorContext context)
|
||||
{
|
||||
StringCollection names = new StringCollection();
|
||||
|
||||
if (string.Equals(context.PropertyDescriptor.Name, "OwnerActivityName", StringComparison.Ordinal))
|
||||
{
|
||||
ISelectionService selectionService = context.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
if (selectionService != null && selectionService.SelectionCount == 1 && selectionService.PrimarySelection is Activity)
|
||||
{
|
||||
// add empty string as an option
|
||||
//
|
||||
names.Add(string.Empty);
|
||||
|
||||
Activity currentActivity = selectionService.PrimarySelection as Activity;
|
||||
|
||||
foreach (Activity activity in GetEnclosingCompositeActivities(currentActivity))
|
||||
{
|
||||
string activityId = activity.QualifiedName;
|
||||
if (!names.Contains(activityId))
|
||||
{
|
||||
names.Add(activityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
internal static LogicalChannel GetLogicalChannel(Activity activity,
|
||||
ChannelToken endpoint,
|
||||
Type contractType)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
if (endpoint == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpoint");
|
||||
}
|
||||
if (contractType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
}
|
||||
|
||||
return GetLogicalChannel(activity, endpoint.Name, endpoint.OwnerActivityName, contractType);
|
||||
}
|
||||
|
||||
internal static LogicalChannel GetLogicalChannel(Activity activity,
|
||||
string name,
|
||||
string ownerActivityName,
|
||||
Type contractType)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("name",
|
||||
SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
|
||||
}
|
||||
if (contractType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
}
|
||||
|
||||
Activity contextActivity = activity.ContextActivity;
|
||||
Activity owner = null;
|
||||
|
||||
if (contextActivity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ownerActivityName))
|
||||
{
|
||||
owner = contextActivity.RootActivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (contextActivity != null)
|
||||
{
|
||||
owner = contextActivity.GetActivityByName(ownerActivityName, true);
|
||||
if (owner != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
contextActivity = contextActivity.Parent;
|
||||
if (contextActivity != null)
|
||||
{
|
||||
contextActivity = contextActivity.ContextActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (owner == null && !string.IsNullOrEmpty(ownerActivityName))
|
||||
{
|
||||
owner = Helpers.ParseActivityForBind(activity, ownerActivityName);
|
||||
}
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
LogicalChannel logicalChannel = null;
|
||||
|
||||
LogicalChannelCollection collection =
|
||||
owner.GetValue(LogicalChannelCollection.LogicalChannelCollectionProperty) as LogicalChannelCollection;
|
||||
if (collection == null)
|
||||
{
|
||||
collection = new LogicalChannelCollection();
|
||||
owner.SetValue(LogicalChannelCollection.LogicalChannelCollectionProperty, collection);
|
||||
|
||||
logicalChannel = new LogicalChannel(name, contractType);
|
||||
collection.Add(logicalChannel);
|
||||
}
|
||||
else if (!collection.Contains(name))
|
||||
{
|
||||
logicalChannel = new LogicalChannel(name, contractType);
|
||||
collection.Add(logicalChannel);
|
||||
}
|
||||
else
|
||||
{
|
||||
logicalChannel = collection[name];
|
||||
}
|
||||
|
||||
if (logicalChannel.ContractType != contractType)
|
||||
{
|
||||
logicalChannel = null;
|
||||
}
|
||||
|
||||
return logicalChannel;
|
||||
}
|
||||
|
||||
internal static LogicalChannel Register(Activity activity,
|
||||
ChannelToken endpoint,
|
||||
Type contractType)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
if (endpoint == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpoint");
|
||||
}
|
||||
if (contractType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
}
|
||||
|
||||
LogicalChannel logicalChannel = GetLogicalChannel(activity, endpoint, contractType);
|
||||
if (logicalChannel == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_FailedToRegisterChannel, endpoint.Name)));
|
||||
}
|
||||
|
||||
return logicalChannel;
|
||||
}
|
||||
|
||||
private static IEnumerable GetEnclosingCompositeActivities(Activity startActivity)
|
||||
{
|
||||
Activity currentActivity = null;
|
||||
Stack<Activity> activityStack = new Stack<Activity>();
|
||||
activityStack.Push(startActivity);
|
||||
|
||||
while ((currentActivity = activityStack.Pop()) != null)
|
||||
{
|
||||
if (currentActivity.Enabled)
|
||||
{
|
||||
yield return currentActivity;
|
||||
}
|
||||
activityStack.Push(currentActivity.Parent);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
//----------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//----------------------------------------------------------------
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
using System.Workflow.Runtime;
|
||||
using System.Globalization;
|
||||
|
||||
internal sealed class ChannelTokenTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return (sourceType == typeof(string));
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return (destinationType == typeof(string));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||
{
|
||||
object convertedValue = null;
|
||||
string endpointName = value as String;
|
||||
if (!String.IsNullOrEmpty(endpointName))
|
||||
{
|
||||
foreach (object obj in GetStandardValues(context))
|
||||
{
|
||||
ChannelToken endpoint = obj as ChannelToken;
|
||||
if (endpoint != null && endpoint.Name == endpointName)
|
||||
{
|
||||
convertedValue = endpoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (convertedValue == null)
|
||||
{
|
||||
convertedValue = new ChannelToken(endpointName);
|
||||
}
|
||||
}
|
||||
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
object convertedValue = null;
|
||||
ChannelToken endpoint = value as ChannelToken;
|
||||
if (destinationType == typeof(string) && endpoint != null)
|
||||
{
|
||||
convertedValue = endpoint.Name;
|
||||
}
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
PropertyDescriptorCollection properties = base.GetProperties(context, value, attributes);
|
||||
ArrayList props = new ArrayList(properties);
|
||||
return new PropertyDescriptorCollection((PropertyDescriptor[]) props.ToArray(typeof(PropertyDescriptor)));
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
Activity activity = context.Instance as Activity;
|
||||
if (activity != null)
|
||||
{
|
||||
foreach (Activity preceedingActivity in GetPreceedingActivities(activity))
|
||||
{
|
||||
PropertyDescriptor endpointProperty = TypeDescriptor.GetProperties(preceedingActivity)["ChannelToken"] as PropertyDescriptor;
|
||||
if (endpointProperty != null)
|
||||
{
|
||||
ChannelToken endpoint = endpointProperty.GetValue(preceedingActivity) as ChannelToken;
|
||||
if (endpoint != null && !values.Contains(endpoint))
|
||||
{
|
||||
values.Add(endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new StandardValuesCollection(values);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable GetContainedActivities(CompositeActivity activity)
|
||||
{
|
||||
if (!activity.Enabled)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (Activity containedActivity in activity.Activities)
|
||||
{
|
||||
if (containedActivity.Enabled)
|
||||
{
|
||||
yield return containedActivity;
|
||||
|
||||
if (containedActivity is CompositeActivity)
|
||||
{
|
||||
foreach (Activity nestedActivity in GetContainedActivities((CompositeActivity) containedActivity))
|
||||
{
|
||||
if (nestedActivity.Enabled)
|
||||
{
|
||||
yield return nestedActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerable GetPreceedingActivities(Activity startActivity)
|
||||
{
|
||||
Activity currentActivity = null;
|
||||
Stack<Activity> activityStack = new Stack<Activity>();
|
||||
activityStack.Push(startActivity);
|
||||
|
||||
while ((currentActivity = activityStack.Pop()) != null)
|
||||
{
|
||||
if (currentActivity.Parent != null)
|
||||
{
|
||||
foreach (Activity siblingActivity in currentActivity.Parent.Activities)
|
||||
{
|
||||
if (siblingActivity == currentActivity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siblingActivity.Enabled)
|
||||
{
|
||||
yield return siblingActivity;
|
||||
|
||||
if (siblingActivity is CompositeActivity)
|
||||
{
|
||||
foreach (Activity containedActivity in GetContainedActivities((CompositeActivity) siblingActivity))
|
||||
{
|
||||
yield return containedActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
activityStack.Push(currentActivity.Parent);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
[DesignerSerializer(typeof(DependencyObjectCodeDomSerializer), typeof(CodeDomSerializer))]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ContextToken : DependencyObject, IPropertyValueProvider
|
||||
{
|
||||
public const string RootContextName = "(RootContext)";
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
|
||||
internal static readonly DependencyProperty NameProperty =
|
||||
DependencyProperty.Register("Name",
|
||||
typeof(string),
|
||||
typeof(ContextToken),
|
||||
new PropertyMetadata(null,
|
||||
DependencyPropertyOptions.Metadata,
|
||||
new Attribute[] { new BrowsableAttribute(false) }));
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
|
||||
internal static readonly DependencyProperty OwnerActivityNameProperty =
|
||||
DependencyProperty.Register("OwnerActivityName",
|
||||
typeof(string),
|
||||
typeof(ContextToken),
|
||||
new PropertyMetadata(null,
|
||||
DependencyPropertyOptions.Metadata,
|
||||
new Attribute[] { new TypeConverterAttribute(typeof(PropertyValueProviderTypeConverter)) }));
|
||||
|
||||
public ContextToken()
|
||||
{
|
||||
this.Name = ContextToken.RootContextName;
|
||||
}
|
||||
|
||||
public ContextToken(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("name",
|
||||
SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
|
||||
}
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(null)]
|
||||
[SR2Description(SR2DescriptionAttribute.ContextToken_Name_Description)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(NameProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(NameProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[TypeConverter(typeof(PropertyValueProviderTypeConverter))]
|
||||
[SR2Description(SR2DescriptionAttribute.ContextToken_OwnerActivityName_Description)]
|
||||
public string OwnerActivityName
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(OwnerActivityNameProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetValue(OwnerActivityNameProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsRootContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.OwnerActivityName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Compare(this.Name, ContextToken.RootContextName, StringComparison.Ordinal) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ICollection IPropertyValueProvider.GetPropertyValues(ITypeDescriptorContext context)
|
||||
{
|
||||
StringCollection names = new StringCollection();
|
||||
|
||||
if (string.Equals(context.PropertyDescriptor.Name, "OwnerActivityName", StringComparison.Ordinal))
|
||||
{
|
||||
ISelectionService selectionService = context.GetService(typeof(ISelectionService)) as ISelectionService;
|
||||
if (selectionService != null && selectionService.SelectionCount == 1 && selectionService.PrimarySelection is Activity)
|
||||
{
|
||||
// add empty string as an option
|
||||
//
|
||||
names.Add(string.Empty);
|
||||
|
||||
Activity currentActivity = selectionService.PrimarySelection as Activity;
|
||||
|
||||
foreach (Activity activity in GetEnclosingCompositeActivities(currentActivity))
|
||||
{
|
||||
string activityId = activity.QualifiedName;
|
||||
if (!names.Contains(activityId))
|
||||
{
|
||||
names.Add(activityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
internal static ReceiveContext GetReceiveContext(Activity activity,
|
||||
string contextName,
|
||||
string ownerActivityName)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
if (string.IsNullOrEmpty(contextName))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("contextToken",
|
||||
SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
|
||||
}
|
||||
|
||||
Activity contextActivity = activity.ContextActivity;
|
||||
Activity owner = null;
|
||||
|
||||
if (contextActivity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ownerActivityName))
|
||||
{
|
||||
owner = contextActivity.RootActivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (contextActivity != null)
|
||||
{
|
||||
owner = contextActivity.GetActivityByName(ownerActivityName, true);
|
||||
if (owner != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
contextActivity = contextActivity.Parent;
|
||||
if (contextActivity != null)
|
||||
{
|
||||
contextActivity = contextActivity.ContextActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
owner = Helpers.ParseActivityForBind(activity, ownerActivityName);
|
||||
}
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
ReceiveContextCollection collection =
|
||||
owner.GetValue(ReceiveContextCollection.ReceiveContextCollectionProperty) as ReceiveContextCollection;
|
||||
if (collection == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!collection.Contains(contextName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ReceiveContext receiveContext = collection[contextName];
|
||||
receiveContext.EnsureInitialized(owner.ContextGuid);
|
||||
|
||||
return receiveContext;
|
||||
}
|
||||
|
||||
internal static ReceiveContext GetRootReceiveContext(Activity activity)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
|
||||
Activity contextActivity = activity.ContextActivity;
|
||||
if (contextActivity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
Activity owner = contextActivity.RootActivity;
|
||||
if (owner == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
ReceiveContextCollection collection =
|
||||
owner.GetValue(ReceiveContextCollection.ReceiveContextCollectionProperty) as ReceiveContextCollection;
|
||||
if (collection == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!collection.Contains(ContextToken.RootContextName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ReceiveContext receiveContext = collection[ContextToken.RootContextName];
|
||||
receiveContext.EnsureInitialized(owner.ContextGuid);
|
||||
|
||||
return receiveContext;
|
||||
}
|
||||
|
||||
internal static void Register(ReceiveActivity activity, Guid workflowId)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
|
||||
ContextToken contextToken = activity.ContextToken;
|
||||
|
||||
if (contextToken == null)
|
||||
{
|
||||
RegisterRootReceiveContext(activity, workflowId);
|
||||
}
|
||||
else if (contextToken.IsRootContext)
|
||||
{
|
||||
RegisterRootReceiveContext(activity, workflowId);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegisterReceiveContext(activity, workflowId, contextToken.Name, contextToken.OwnerActivityName);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable GetEnclosingCompositeActivities(Activity startActivity)
|
||||
{
|
||||
Activity currentActivity = null;
|
||||
Stack<Activity> activityStack = new Stack<Activity>();
|
||||
activityStack.Push(startActivity);
|
||||
|
||||
while ((currentActivity = activityStack.Pop()) != null)
|
||||
{
|
||||
if (currentActivity.Enabled)
|
||||
{
|
||||
yield return currentActivity;
|
||||
}
|
||||
activityStack.Push(currentActivity.Parent);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
static void RegisterReceiveContext(ReceiveActivity activity,
|
||||
Guid workflowId,
|
||||
string contextName,
|
||||
string ownerActivityName)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
if (string.IsNullOrEmpty(contextName))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("contextName",
|
||||
SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
|
||||
}
|
||||
|
||||
Activity contextActivity = activity.ContextActivity;
|
||||
Activity owner = null;
|
||||
|
||||
if (contextActivity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ownerActivityName))
|
||||
{
|
||||
owner = contextActivity.RootActivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (contextActivity != null)
|
||||
{
|
||||
owner = contextActivity.GetActivityByName(ownerActivityName, true);
|
||||
if (owner != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
contextActivity = contextActivity.Parent;
|
||||
if (contextActivity != null)
|
||||
{
|
||||
contextActivity = contextActivity.ContextActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
owner = Helpers.ParseActivityForBind(activity, ownerActivityName);
|
||||
}
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
ReceiveContextCollection collection =
|
||||
owner.GetValue(ReceiveContextCollection.ReceiveContextCollectionProperty) as ReceiveContextCollection;
|
||||
if (collection == null)
|
||||
{
|
||||
collection = new ReceiveContextCollection();
|
||||
owner.SetValue(ReceiveContextCollection.ReceiveContextCollectionProperty, collection);
|
||||
}
|
||||
|
||||
if (!collection.Contains(contextName))
|
||||
{
|
||||
collection.Add(new ReceiveContext(contextName, workflowId, false));
|
||||
}
|
||||
}
|
||||
|
||||
static void RegisterRootReceiveContext(Activity activity, Guid workflowId)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
|
||||
}
|
||||
|
||||
Activity contextActivity = activity.ContextActivity;
|
||||
if (contextActivity == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
Activity owner = contextActivity.RootActivity;
|
||||
if (owner == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new InvalidOperationException(SR2.GetString(SR2.Error_ContextOwnerActivityMissing)));
|
||||
}
|
||||
|
||||
ReceiveContextCollection collection =
|
||||
owner.GetValue(ReceiveContextCollection.ReceiveContextCollectionProperty) as ReceiveContextCollection;
|
||||
if (collection == null)
|
||||
{
|
||||
collection = new ReceiveContextCollection();
|
||||
owner.SetValue(ReceiveContextCollection.ReceiveContextCollectionProperty, collection);
|
||||
}
|
||||
|
||||
if (!collection.Contains(ContextToken.RootContextName))
|
||||
{
|
||||
collection.Add(new ReceiveContext(ContextToken.RootContextName, workflowId, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
//----------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//----------------------------------------------------------------
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
using System.Workflow.Runtime;
|
||||
using System.Globalization;
|
||||
|
||||
internal sealed class ContextTokenTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return (sourceType == typeof(string));
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return (destinationType == typeof(string));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||
{
|
||||
object convertedValue = null;
|
||||
string contextName = value as String;
|
||||
if (!String.IsNullOrEmpty(contextName))
|
||||
{
|
||||
foreach (object obj in GetStandardValues(context))
|
||||
{
|
||||
ContextToken contextToken = obj as ContextToken;
|
||||
if (contextToken != null && contextToken.Name == contextName)
|
||||
{
|
||||
convertedValue = contextToken;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (convertedValue == null)
|
||||
{
|
||||
convertedValue = new ContextToken(contextName);
|
||||
}
|
||||
}
|
||||
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
object convertedValue = null;
|
||||
ContextToken contextToken = value as ContextToken;
|
||||
if (destinationType == typeof(string) && contextToken != null)
|
||||
{
|
||||
convertedValue = contextToken.Name;
|
||||
}
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
PropertyDescriptorCollection properties = base.GetProperties(context, value, attributes);
|
||||
ArrayList props = new ArrayList(properties);
|
||||
return new PropertyDescriptorCollection((PropertyDescriptor[]) props.ToArray(typeof(PropertyDescriptor)));
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
Activity activity = context.Instance as Activity;
|
||||
if (activity != null)
|
||||
{
|
||||
foreach (Activity preceedingActivity in GetPreceedingActivities(activity))
|
||||
{
|
||||
PropertyDescriptor contextTokenProperty = TypeDescriptor.GetProperties(preceedingActivity)["ContextToken"] as PropertyDescriptor;
|
||||
if (contextTokenProperty != null)
|
||||
{
|
||||
ContextToken contextToken = contextTokenProperty.GetValue(preceedingActivity) as ContextToken;
|
||||
if (contextToken != null && !values.Contains(contextToken))
|
||||
{
|
||||
values.Add(contextToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new StandardValuesCollection(values);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable GetContainedActivities(CompositeActivity activity)
|
||||
{
|
||||
if (!activity.Enabled)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (Activity containedActivity in activity.Activities)
|
||||
{
|
||||
if (containedActivity.Enabled)
|
||||
{
|
||||
yield return containedActivity;
|
||||
|
||||
if (containedActivity is CompositeActivity)
|
||||
{
|
||||
foreach (Activity nestedActivity in GetContainedActivities((CompositeActivity) containedActivity))
|
||||
{
|
||||
if (nestedActivity.Enabled)
|
||||
{
|
||||
yield return nestedActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerable GetPreceedingActivities(Activity startActivity)
|
||||
{
|
||||
Activity currentActivity = null;
|
||||
Stack<Activity> activityStack = new Stack<Activity>();
|
||||
activityStack.Push(startActivity);
|
||||
|
||||
while ((currentActivity = activityStack.Pop()) != null)
|
||||
{
|
||||
if (currentActivity.Parent != null)
|
||||
{
|
||||
foreach (Activity siblingActivity in currentActivity.Parent.Activities)
|
||||
{
|
||||
if (siblingActivity == currentActivity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siblingActivity.Enabled)
|
||||
{
|
||||
yield return siblingActivity;
|
||||
|
||||
if (siblingActivity is CompositeActivity)
|
||||
{
|
||||
foreach (Activity containedActivity in GetContainedActivities((CompositeActivity) siblingActivity))
|
||||
{
|
||||
yield return containedActivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
activityStack.Push(currentActivity.Parent);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
#pragma warning disable 1634, 1691
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net.Security;
|
||||
using System.ServiceModel;
|
||||
using System.Reflection;
|
||||
|
||||
internal sealed class ContractMethodInfo : MethodInfo
|
||||
{
|
||||
private Attribute[] attributes = null;
|
||||
private ContractType declaringType;
|
||||
private MethodAttributes methodAttributes;
|
||||
private string name;
|
||||
private ParameterInfo[] parameters;
|
||||
private ParameterInfo returnParam = null;
|
||||
|
||||
internal ContractMethodInfo(ContractType declaringType, OperationInfo operationInfo)
|
||||
{
|
||||
if (declaringType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringType");
|
||||
}
|
||||
if (operationInfo == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo");
|
||||
}
|
||||
if (string.IsNullOrEmpty(operationInfo.Name))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("operationInfo",
|
||||
SR2.GetString(SR2.Error_OperationNameNotSpecified));
|
||||
}
|
||||
|
||||
this.declaringType = declaringType;
|
||||
this.name = operationInfo.Name;
|
||||
this.methodAttributes = MethodAttributes.Public |
|
||||
MethodAttributes.Abstract |
|
||||
MethodAttributes.Virtual;
|
||||
|
||||
SortedList<int, ContractMethodParameterInfo> localParameters =
|
||||
new SortedList<int, ContractMethodParameterInfo>();
|
||||
|
||||
foreach (OperationParameterInfo operationParameterInfo in operationInfo.Parameters)
|
||||
{
|
||||
ContractMethodParameterInfo parameterInfo =
|
||||
new ContractMethodParameterInfo(this, operationParameterInfo);
|
||||
if (parameterInfo.Position == -1)
|
||||
{
|
||||
this.returnParam = parameterInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
localParameters.Add(parameterInfo.Position, parameterInfo);
|
||||
}
|
||||
}
|
||||
|
||||
this.parameters = new ParameterInfo[localParameters.Count];
|
||||
foreach (ContractMethodParameterInfo paramInfo in localParameters.Values)
|
||||
{
|
||||
this.parameters[paramInfo.Position] = paramInfo;
|
||||
}
|
||||
|
||||
if (this.returnParam == null)
|
||||
{
|
||||
OperationParameterInfo returnParameterInfo = new OperationParameterInfo();
|
||||
returnParameterInfo.Position = -1;
|
||||
returnParameterInfo.ParameterType = typeof(void);
|
||||
|
||||
this.returnParam = new ContractMethodParameterInfo(this, returnParameterInfo);
|
||||
}
|
||||
|
||||
OperationContractAttribute operationContract = new OperationContractAttribute();
|
||||
if (operationInfo.HasProtectionLevel && operationInfo.ProtectionLevel != null)
|
||||
{
|
||||
operationContract.ProtectionLevel = (ProtectionLevel) operationInfo.ProtectionLevel;
|
||||
}
|
||||
operationContract.IsOneWay = operationInfo.IsOneWay;
|
||||
|
||||
this.attributes = new Attribute[] { operationContract };
|
||||
|
||||
declaringType.AddMethod(this);
|
||||
}
|
||||
|
||||
public override MethodAttributes Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.methodAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.declaringType;
|
||||
}
|
||||
}
|
||||
public override RuntimeMethodHandle MethodHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning suppress 56503
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new NotImplementedException(SR2.GetString(SR2.Error_RuntimeNotSupported)));
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type ReflectedType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.declaringType;
|
||||
}
|
||||
}
|
||||
|
||||
public override ParameterInfo ReturnParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.returnParam;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type ReturnType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.returnParam == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.returnParam.ParameterType;
|
||||
}
|
||||
}
|
||||
|
||||
public override ICustomAttributeProvider ReturnTypeCustomAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ReturnType;
|
||||
}
|
||||
}
|
||||
|
||||
public override MethodInfo GetBaseDefinition()
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new NotImplementedException());
|
||||
}
|
||||
|
||||
public override object[] GetCustomAttributes(bool inherit)
|
||||
{
|
||||
return GetCustomAttributes(typeof(object), inherit);
|
||||
}
|
||||
|
||||
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
||||
{
|
||||
if (attributeType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attributeType");
|
||||
}
|
||||
return ServiceOperationHelpers.GetCustomAttributes(attributeType, this.attributes);
|
||||
}
|
||||
|
||||
public override MethodImplAttributes GetMethodImplementationFlags()
|
||||
{
|
||||
return MethodImplAttributes.IL;
|
||||
}
|
||||
|
||||
public override ParameterInfo[] GetParameters()
|
||||
{
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public override object Invoke(object obj,
|
||||
BindingFlags invokeAttr,
|
||||
Binder binder,
|
||||
object[] parameters,
|
||||
CultureInfo culture)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new NotImplementedException(SR2.GetString(SR2.Error_RuntimeNotSupported)));
|
||||
}
|
||||
|
||||
public override bool IsDefined(Type attributeType, bool inherit)
|
||||
{
|
||||
if (attributeType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attributeType");
|
||||
}
|
||||
|
||||
return ServiceOperationHelpers.IsDefined(attributeType, attributes);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
System.Workflow.Activities.ContractType.MemberSignature signature =
|
||||
new ContractType.MemberSignature(this);
|
||||
return signature.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.ServiceModel;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
|
||||
internal sealed class ContractMethodParameterInfo : ParameterInfo
|
||||
{
|
||||
internal ContractMethodParameterInfo(ContractMethodInfo member,
|
||||
OperationParameterInfo parameterInfo)
|
||||
{
|
||||
if (member == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("member");
|
||||
}
|
||||
if (parameterInfo == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameterInfo");
|
||||
}
|
||||
|
||||
this.AttrsImpl = parameterInfo.Attributes;
|
||||
|
||||
this.MemberImpl = member;
|
||||
this.PositionImpl = parameterInfo.Position;
|
||||
if (parameterInfo.Position >= 0)
|
||||
{
|
||||
this.NameImpl = parameterInfo.Name;
|
||||
|
||||
string typeName = parameterInfo.ParameterType.FullName;
|
||||
if ((this.AttrsImpl & ParameterAttributes.Out) > 0)
|
||||
{
|
||||
typeName += '&'; // Append with & for (ref & out) parameter types
|
||||
|
||||
if (this.Member.DeclaringType is DesignTimeType)
|
||||
{
|
||||
this.ClassImpl = (this.Member.DeclaringType as DesignTimeType).ResolveType(typeName);
|
||||
}
|
||||
else if (parameterInfo.ParameterType is DesignTimeType)
|
||||
{
|
||||
this.ClassImpl = (parameterInfo.ParameterType as DesignTimeType).ResolveType(typeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeName += ", " + parameterInfo.ParameterType.Assembly.FullName;
|
||||
this.ClassImpl = Type.GetType(typeName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ClassImpl = parameterInfo.ParameterType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ClassImpl = parameterInfo.ParameterType;
|
||||
}
|
||||
}
|
||||
|
||||
public override object[] GetCustomAttributes(bool inherit)
|
||||
{
|
||||
return GetCustomAttributes(typeof(object), inherit);
|
||||
}
|
||||
|
||||
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
|
||||
{
|
||||
if (attributeType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attributeType");
|
||||
}
|
||||
|
||||
if (this.ParameterType == null)
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
return this.ParameterType.GetCustomAttributes(attributeType, inherit);
|
||||
}
|
||||
|
||||
public override bool IsDefined(Type attributeType, bool inherit)
|
||||
{
|
||||
if (attributeType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attributeType");
|
||||
}
|
||||
|
||||
if (this.ParameterType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.ParameterType.IsDefined(attributeType, inherit);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
internal class EditableLabelControl : Panel
|
||||
{
|
||||
public TextBox TextBox;
|
||||
Label label;
|
||||
|
||||
public EditableLabelControl()
|
||||
{
|
||||
label = new Label();
|
||||
TextBox = new TextBox();
|
||||
this.Controls.Add(label);
|
||||
label.BackColor = Color.Transparent;
|
||||
label.AutoEllipsis = true;
|
||||
label.Dock = DockStyle.Fill;
|
||||
this.BackColor = Color.Transparent;
|
||||
this.label.Click += new EventHandler(label_Click);
|
||||
}
|
||||
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
label.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
label.ForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return TextBox.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
label.Text = value;
|
||||
TextBox.Text = value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableEditMode()
|
||||
{
|
||||
if (this.Controls.Contains(TextBox))
|
||||
{
|
||||
this.Controls.Remove(TextBox);
|
||||
}
|
||||
if (!this.Controls.Contains(label))
|
||||
{
|
||||
this.Controls.Add(label);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableEditMode()
|
||||
{
|
||||
TextBox.Text = label.Text;
|
||||
TextBox.ForeColor = label.ForeColor;
|
||||
TextBox.Font = this.Font;
|
||||
TextBox.Dock = DockStyle.Fill;
|
||||
TextBox.BorderStyle = BorderStyle.Fixed3D;
|
||||
this.Controls.Remove(label);
|
||||
this.Controls.Add(TextBox);
|
||||
this.TextBox.LostFocus += new EventHandler(textBox_LostFocus);
|
||||
}
|
||||
|
||||
void label_Click(object sender, EventArgs e)
|
||||
{
|
||||
EnableEditMode();
|
||||
}
|
||||
|
||||
void textBox_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
DisableEditMode();
|
||||
this.Text = TextBox.Text;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
internal partial class GradientPanel : Panel
|
||||
{
|
||||
protected Rectangle frameRect;
|
||||
private Color baseColor;
|
||||
private Color borderColor;
|
||||
private bool dropShadow;
|
||||
int glossHeight;
|
||||
private bool glossy;
|
||||
private Color lightingColor;
|
||||
private int radius;
|
||||
|
||||
public GradientPanel()
|
||||
{
|
||||
BaseColor = Color.FromArgb(255, 255, 255, 255);
|
||||
LightingColor = Color.FromArgb(255, 176, 186, 196);
|
||||
Radius = 7;
|
||||
this.DoubleBuffered = true;
|
||||
}
|
||||
|
||||
public Color BaseColor
|
||||
{
|
||||
get { return baseColor; }
|
||||
set { baseColor = value; }
|
||||
}
|
||||
|
||||
public Color BorderColor
|
||||
{
|
||||
get { return borderColor; }
|
||||
set { borderColor = value; }
|
||||
}
|
||||
|
||||
public bool DropShadow
|
||||
{
|
||||
get { return dropShadow; }
|
||||
set { dropShadow = value; }
|
||||
}
|
||||
|
||||
public bool Glossy
|
||||
{
|
||||
get { return glossy; }
|
||||
set { glossy = value; }
|
||||
}
|
||||
|
||||
public Color LightingColor
|
||||
{
|
||||
get { return lightingColor; }
|
||||
set { lightingColor = value; }
|
||||
}
|
||||
|
||||
public int Radius
|
||||
{
|
||||
get { return radius; }
|
||||
set { radius = value; }
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
this.SuspendLayout();
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
if (DropShadow)
|
||||
{
|
||||
frameRect = new Rectangle(6, 0, this.Size.Width - 14, this.Size.Height - 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
frameRect = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);
|
||||
}
|
||||
frameRect.X -= Margin.Left;
|
||||
frameRect.Y -= Margin.Top;
|
||||
frameRect.Width += Margin.Left + Margin.Right;
|
||||
frameRect.Height += Margin.Top + Margin.Bottom;
|
||||
Rectangle shadowRect = new Rectangle(frameRect.X, frameRect.Y + 6, frameRect.Width, frameRect.Height - 5);
|
||||
glossHeight = frameRect.Height / 3;
|
||||
Brush glossBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + glossHeight + 1), Color.FromArgb(120, 255, 255, 255), Color.FromArgb(60, 255, 255, 255)); // SolidBrush(Color.FromArgb(32, 255, 255, 255));
|
||||
Brush frameBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Bottom), BaseColor, LightingColor);
|
||||
Graphics outputGraphics = e.Graphics;
|
||||
if (DropShadow)
|
||||
{
|
||||
shadowRect = DropRoundedRectangleShadow(shadowRect, outputGraphics);
|
||||
}
|
||||
e.Graphics.FillPath(frameBrush, RoundedRect(frameRect));
|
||||
if (Glossy)
|
||||
{
|
||||
e.Graphics.FillPath(glossBrush, RoundedRectTopHalf(frameRect));
|
||||
}
|
||||
e.Graphics.DrawPath(new Pen(this.BorderColor), RoundedRect(frameRect));
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
private Rectangle DropRoundedRectangleShadow(Rectangle shadowRect, Graphics outputGraphics)
|
||||
{
|
||||
int shadowIntensity = 1;
|
||||
using (Pen shadowPen = new Pen(Color.FromArgb(shadowIntensity, 0, 0, 0)))
|
||||
{
|
||||
shadowPen.Width = 16;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
outputGraphics.DrawPath(shadowPen, RoundedRect(shadowRect));
|
||||
shadowPen.Color = Color.FromArgb(shadowIntensity - 1, 0, 0, 0);
|
||||
shadowIntensity += 8;
|
||||
shadowPen.Width = shadowPen.Width - 2;;
|
||||
}
|
||||
return shadowRect;
|
||||
}
|
||||
}
|
||||
|
||||
private GraphicsPath RoundedRect(Rectangle frame)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
if (Radius < 1)
|
||||
{
|
||||
path.AddRectangle(frame);
|
||||
return path;
|
||||
}
|
||||
int diameter = Radius * 2;
|
||||
Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter);
|
||||
path.AddArc(arc, 180, 90);
|
||||
arc.X = frame.Right - diameter;
|
||||
path.AddArc(arc, 270, 90);
|
||||
arc.Y = frame.Bottom - diameter;
|
||||
path.AddArc(arc, 0, 90);
|
||||
arc.X = frame.Left;
|
||||
path.AddArc(arc, 90, 90);
|
||||
path.CloseFigure();
|
||||
return path;
|
||||
}
|
||||
|
||||
private GraphicsPath RoundedRectTopHalf(Rectangle frame)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
int diameter = Radius * 2;
|
||||
Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter);
|
||||
path.AddArc(arc, 180, 90);
|
||||
arc.X = frame.Right - diameter;
|
||||
path.AddArc(arc, 270, 90);
|
||||
path.AddLine(new Point(frame.Right, frame.Top + glossHeight), new Point(frame.Left, frame.Top + glossHeight));
|
||||
path.CloseFigure();
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
|
||||
internal sealed class ListItemDetailViewAttribute : Attribute
|
||||
{
|
||||
private Type viewType;
|
||||
|
||||
public ListItemDetailViewAttribute(Type viewType)
|
||||
{
|
||||
this.ViewType = viewType;
|
||||
}
|
||||
|
||||
public Type ViewType
|
||||
{
|
||||
get { return viewType; }
|
||||
set { viewType = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
|
||||
internal sealed class ListItemViewAttribute : Attribute
|
||||
{
|
||||
private Type viewType;
|
||||
|
||||
public ListItemViewAttribute(Type viewType)
|
||||
{
|
||||
this.ViewType = viewType;
|
||||
}
|
||||
|
||||
public Type ViewType
|
||||
{
|
||||
get { return viewType; }
|
||||
set { viewType = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
internal class ListItemViewControl : UserControl
|
||||
{
|
||||
private DrawItemState drawItemState;
|
||||
|
||||
private object item;
|
||||
private IServiceProvider serviceProvider;
|
||||
|
||||
public virtual event EventHandler ItemChanged;
|
||||
|
||||
public virtual DrawItemState DrawItemState
|
||||
{
|
||||
get { return drawItemState; }
|
||||
set { drawItemState = value; }
|
||||
}
|
||||
|
||||
public virtual object Item
|
||||
{
|
||||
get { return item; }
|
||||
set
|
||||
{
|
||||
item = value;
|
||||
if (ItemChanged != null)
|
||||
{
|
||||
ItemChanged.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IServiceProvider ServiceProvider
|
||||
{
|
||||
get { return serviceProvider; }
|
||||
set { serviceProvider = value; }
|
||||
}
|
||||
|
||||
public virtual void UpdateView()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.ServiceModel;
|
||||
|
||||
abstract class NamedObjectList<T> : List<T>
|
||||
{
|
||||
int suffixGenerator;
|
||||
|
||||
protected abstract string GeneratedNameFormatResource
|
||||
{ get; }
|
||||
|
||||
public T CreateWithUniqueName()
|
||||
{
|
||||
string generatedName;
|
||||
do
|
||||
{
|
||||
generatedName = SR2.GetString(this.GeneratedNameFormatResource, ++this.suffixGenerator);
|
||||
} while (this.Find(generatedName) != null);
|
||||
|
||||
return this.CreateObject(generatedName);
|
||||
}
|
||||
|
||||
public T Find(string name)
|
||||
{
|
||||
T result = default(T);
|
||||
foreach (T obj in this)
|
||||
{
|
||||
if (this.GetName(obj) == name)
|
||||
{
|
||||
result = obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract T CreateObject(string name);
|
||||
protected abstract string GetName(T obj);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,204 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
partial class OperationPickerDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OperationPickerDialog));
|
||||
this.operationsToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
|
||||
this.importContractButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
|
||||
this.addOperationButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.operationsPanel = new System.Workflow.Activities.Design.GradientPanel();
|
||||
this.operationsListBox = new System.Workflow.Activities.Design.RichListBox();
|
||||
this.detailsViewPanel = new System.Workflow.Activities.Design.GradientPanel();
|
||||
this.footerPanel = new System.Workflow.Activities.Design.GradientPanel();
|
||||
this.operationsToolStrip.SuspendLayout();
|
||||
this.operationsPanel.SuspendLayout();
|
||||
this.footerPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// operationsToolStrip
|
||||
//
|
||||
this.operationsToolStrip.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.operationsToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.operationsToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripLabel1,
|
||||
this.importContractButton,
|
||||
this.toolStripButton1,
|
||||
this.addOperationButton});
|
||||
resources.ApplyResources(this.operationsToolStrip, "operationsToolStrip");
|
||||
this.operationsToolStrip.Name = "operationsToolStrip";
|
||||
this.operationsToolStrip.Stretch = true;
|
||||
this.operationsToolStrip.TabStop = true;
|
||||
//
|
||||
// toolStripLabel1
|
||||
//
|
||||
this.toolStripLabel1.Name = "toolStripLabel1";
|
||||
this.toolStripLabel1.Padding = new System.Windows.Forms.Padding(15, 0, 0, 0);
|
||||
resources.ApplyResources(this.toolStripLabel1, "toolStripLabel1");
|
||||
//
|
||||
// importContractButton
|
||||
//
|
||||
this.importContractButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.importContractButton.Image = global::System.ServiceModel.ImageResources.Import;
|
||||
resources.ApplyResources(this.importContractButton, "importContractButton");
|
||||
this.importContractButton.Name = "importContractButton";
|
||||
//
|
||||
// toolStripButton1
|
||||
//
|
||||
this.toolStripButton1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.toolStripButton1.Image = global::System.ServiceModel.ImageResources.AddContract;
|
||||
resources.ApplyResources(this.toolStripButton1, "toolStripButton1");
|
||||
this.toolStripButton1.Name = "toolStripButton1";
|
||||
//
|
||||
// addOperationButton
|
||||
//
|
||||
this.addOperationButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.addOperationButton.Image = global::System.ServiceModel.ImageResources.AddOperation;
|
||||
resources.ApplyResources(this.addOperationButton, "addOperationButton");
|
||||
this.addOperationButton.Name = "addOperationButton";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// operationsPanel
|
||||
//
|
||||
resources.ApplyResources(this.operationsPanel, "operationsPanel");
|
||||
this.operationsPanel.BaseColor = System.Drawing.SystemColors.Window;
|
||||
this.operationsPanel.BorderColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.operationsPanel.Controls.Add(this.operationsListBox);
|
||||
this.operationsPanel.DropShadow = false;
|
||||
this.operationsPanel.Glossy = false;
|
||||
this.operationsPanel.LightingColor = System.Drawing.SystemColors.Window;
|
||||
this.operationsPanel.Name = "operationsPanel";
|
||||
this.operationsPanel.Radius = 3;
|
||||
this.operationsPanel.Padding = new System.Windows.Forms.Padding(3);
|
||||
//
|
||||
// operationsListBox
|
||||
//
|
||||
this.operationsListBox.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.operationsListBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.operationsListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.operationsListBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
|
||||
this.operationsListBox.Editable = false;
|
||||
resources.ApplyResources(this.operationsListBox, "operationsListBox");
|
||||
this.operationsListBox.FormattingEnabled = true;
|
||||
this.operationsListBox.Name = "operationsListBox";
|
||||
this.operationsListBox.SelectedItemViewControl = null;
|
||||
//
|
||||
// detailsViewPanel
|
||||
//
|
||||
resources.ApplyResources(this.detailsViewPanel, "detailsViewPanel");
|
||||
this.detailsViewPanel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.detailsViewPanel.BaseColor = System.Drawing.SystemColors.Control;
|
||||
this.detailsViewPanel.BorderColor = System.Drawing.Color.Transparent;
|
||||
this.detailsViewPanel.DropShadow = false;
|
||||
this.detailsViewPanel.Glossy = false;
|
||||
this.detailsViewPanel.LightingColor = System.Drawing.SystemColors.Control;
|
||||
this.detailsViewPanel.Name = "detailsViewPanel";
|
||||
this.detailsViewPanel.Radius = 3;
|
||||
//
|
||||
// footerPanel
|
||||
//
|
||||
this.footerPanel.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.footerPanel.BaseColor = System.Drawing.Color.Transparent;
|
||||
this.footerPanel.BorderColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.footerPanel.Controls.Add(this.cancelButton);
|
||||
this.footerPanel.Controls.Add(this.okButton);
|
||||
resources.ApplyResources(this.footerPanel, "footerPanel");
|
||||
this.footerPanel.DropShadow = false;
|
||||
this.footerPanel.Glossy = false;
|
||||
this.footerPanel.LightingColor = System.Drawing.Color.Transparent;
|
||||
this.footerPanel.Name = "footerPanel";
|
||||
this.footerPanel.Radius = 1;
|
||||
//
|
||||
// OperationPickerDialog
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13f);
|
||||
this.AutoSize = true;
|
||||
this.AcceptButton = this.okButton;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.CancelButton = this.cancelButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.Controls.Add(this.operationsToolStrip);
|
||||
this.Controls.Add(this.operationsPanel);
|
||||
this.Controls.Add(this.detailsViewPanel);
|
||||
this.Controls.Add(this.footerPanel);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "OperationPickerDialog";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Load += new System.EventHandler(this.OperationPickerDialogLoad);
|
||||
this.operationsToolStrip.ResumeLayout(false);
|
||||
this.operationsToolStrip.PerformLayout();
|
||||
this.operationsPanel.ResumeLayout(false);
|
||||
this.footerPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ToolStrip operationsToolStrip;
|
||||
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
|
||||
private System.Windows.Forms.ToolStripButton importContractButton;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButton1;
|
||||
private System.Windows.Forms.ToolStripButton addOperationButton;
|
||||
private GradientPanel operationsPanel;
|
||||
private RichListBox operationsListBox;
|
||||
private GradientPanel detailsViewPanel;
|
||||
private GradientPanel footerPanel;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.ServiceModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
|
||||
internal class RichListBox : ListBox
|
||||
{
|
||||
ListItemViewControl activeItemDetailViewControl = null;
|
||||
ListItemViewControl activeItemViewControl = null;
|
||||
private bool editable;
|
||||
Dictionary<object, Point> itemLocations;
|
||||
Dictionary<string, Bitmap> listItemBitmapCache = null;
|
||||
Dictionary<string, ListItemViewControl> listItemViewRenderers = null;
|
||||
private IServiceProvider serviceProvider;
|
||||
|
||||
public RichListBox()
|
||||
{
|
||||
this.DrawMode = DrawMode.OwnerDrawVariable;
|
||||
listItemBitmapCache = new Dictionary<string, Bitmap>();
|
||||
listItemViewRenderers = new Dictionary<string, ListItemViewControl>();
|
||||
itemLocations = new Dictionary<object, Point>();
|
||||
this.DoubleBuffered = true;
|
||||
}
|
||||
|
||||
public bool Editable
|
||||
{
|
||||
get { return editable; }
|
||||
set { editable = value; }
|
||||
}
|
||||
|
||||
|
||||
public ListItemViewControl SelectedItemViewControl
|
||||
{
|
||||
get { return activeItemDetailViewControl; }
|
||||
set { activeItemDetailViewControl = value; }
|
||||
}
|
||||
|
||||
|
||||
public IServiceProvider ServiceProvider
|
||||
{
|
||||
set { serviceProvider = value; }
|
||||
}
|
||||
|
||||
public static Type GetDetailViewType(Type editableListItemType)
|
||||
{
|
||||
if (editableListItemType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("editableListItemType");
|
||||
}
|
||||
if (!typeof(object).IsAssignableFrom(editableListItemType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Type viewType = null;
|
||||
object[] attribs = editableListItemType.GetCustomAttributes(typeof(ListItemDetailViewAttribute), true);
|
||||
if ((attribs != null) && (attribs.Length > 0))
|
||||
{
|
||||
ListItemDetailViewAttribute viewAttribute = attribs[0] as ListItemDetailViewAttribute;
|
||||
if (viewAttribute != null)
|
||||
{
|
||||
viewType = viewAttribute.ViewType;
|
||||
}
|
||||
}
|
||||
return viewType;
|
||||
}
|
||||
|
||||
|
||||
public static Type GetItemViewType(Type editableListItemType)
|
||||
{
|
||||
if (editableListItemType == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("editableListItemType");
|
||||
}
|
||||
if (!typeof(object).IsAssignableFrom(editableListItemType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Type viewType = null;
|
||||
object[] attribs = editableListItemType.GetCustomAttributes(typeof(ListItemViewAttribute), true);
|
||||
if ((attribs != null) && (attribs.Length > 0))
|
||||
{
|
||||
ListItemViewAttribute viewAttribute = attribs[0] as ListItemViewAttribute;
|
||||
if (viewAttribute != null)
|
||||
{
|
||||
viewType = viewAttribute.ViewType;
|
||||
}
|
||||
}
|
||||
return viewType;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||
{
|
||||
if (e.Index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Items.Count < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
object itemToDraw = Items[e.Index];
|
||||
if (itemToDraw == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ListItemViewControl listItemRenderer = GetRenderer(itemToDraw);
|
||||
listItemRenderer.DrawItemState = e.State;
|
||||
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
|
||||
{
|
||||
if (Editable)
|
||||
{
|
||||
if (activeItemViewControl != null)
|
||||
{
|
||||
activeItemViewControl.Location = e.Bounds.Location;
|
||||
activeItemViewControl.DrawItemState = e.State;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
listItemRenderer.Item = itemToDraw;
|
||||
listItemRenderer.UpdateView();
|
||||
listItemRenderer.TabStop = false;
|
||||
listItemRenderer.Parent = this;
|
||||
listItemRenderer.Top = -2000;
|
||||
Bitmap rendererBitmap = GetRendererBitmap(itemToDraw);
|
||||
itemLocations[itemToDraw] = e.Bounds.Location;
|
||||
listItemRenderer.DrawToBitmap(rendererBitmap, new Rectangle(new Point(0, 0), listItemRenderer.Size));
|
||||
e.Graphics.DrawImage(rendererBitmap, e.Bounds.Location);
|
||||
}
|
||||
|
||||
protected override void OnMeasureItem(MeasureItemEventArgs e)
|
||||
{
|
||||
base.OnMeasureItem(e);
|
||||
if (e.Index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
object listItem = this.Items[e.Index];
|
||||
if (listItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ListItemViewControl listItemRenderer = GetRenderer(listItem);
|
||||
listItemRenderer.Item = listItem;
|
||||
listItemRenderer.UpdateView();
|
||||
listItemRenderer.TabStop = false;
|
||||
listItemRenderer.Parent = this;
|
||||
listItemRenderer.Top = -2000;
|
||||
listItemRenderer.PerformAutoScale();
|
||||
e.ItemHeight = listItemRenderer.Height;
|
||||
e.ItemWidth = listItemRenderer.Width;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnSelectedIndexChanged(EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.SelectedIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
object selectedItem = Items[this.SelectedIndex];
|
||||
if (selectedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedItemViewControl = Activator.CreateInstance(GetDetailViewType(selectedItem.GetType())) as ListItemViewControl;
|
||||
SelectedItemViewControl.ServiceProvider = this.serviceProvider;
|
||||
SelectedItemViewControl.Item = selectedItem;
|
||||
SelectedItemViewControl.DrawItemState = DrawItemState.Selected;
|
||||
SelectedItemViewControl.ItemChanged += new EventHandler(SelectedItemDetailViewControlItemChanged);
|
||||
SelectedItemViewControl.UpdateView();
|
||||
if (Editable)
|
||||
{
|
||||
if (activeItemViewControl != null)
|
||||
{
|
||||
this.Controls.Remove(activeItemViewControl);
|
||||
}
|
||||
if (selectedItem != null)
|
||||
{
|
||||
|
||||
activeItemViewControl = Activator.CreateInstance(GetItemViewType(selectedItem.GetType())) as ListItemViewControl;
|
||||
if (itemLocations.ContainsKey(selectedItem))
|
||||
{
|
||||
activeItemDetailViewControl.Location = itemLocations[selectedItem];
|
||||
}
|
||||
activeItemViewControl.DrawItemState = DrawItemState.Selected;
|
||||
activeItemViewControl.UpdateView();
|
||||
activeItemViewControl.Item = selectedItem;
|
||||
|
||||
this.Controls.Add(activeItemViewControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
DesignerHelpers.ShowMessage(serviceProvider, exception.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
|
||||
throw;
|
||||
}
|
||||
base.OnSelectedIndexChanged(e);
|
||||
}
|
||||
|
||||
private ListItemViewControl GetRenderer(object listItem)
|
||||
{
|
||||
Type viewType = GetItemViewType(listItem.GetType());
|
||||
|
||||
if (!listItemViewRenderers.ContainsKey(viewType.Name))
|
||||
{
|
||||
listItemViewRenderers.Add(viewType.Name, Activator.CreateInstance(viewType) as ListItemViewControl);
|
||||
}
|
||||
ListItemViewControl listItemRenderer = listItemViewRenderers[viewType.Name];
|
||||
return listItemRenderer;
|
||||
}
|
||||
|
||||
private Bitmap GetRendererBitmap(object listItem)
|
||||
{
|
||||
Type viewType = GetItemViewType(listItem.GetType());
|
||||
ListItemViewControl listItemRenderer = GetRenderer(listItem);
|
||||
if (listItemRenderer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!listItemBitmapCache.ContainsKey(viewType.Name))
|
||||
{
|
||||
listItemBitmapCache.Add(viewType.Name, new Bitmap(listItemRenderer.Size.Width, listItemRenderer.Size.Height));
|
||||
}
|
||||
|
||||
Bitmap rendererBitmap = listItemBitmapCache[viewType.Name];
|
||||
return rendererBitmap;
|
||||
}
|
||||
|
||||
void SelectedItemDetailViewControlItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
internal partial class ServiceContractDetailViewControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServiceContractDetailViewControl));
|
||||
this.contractNameLabel = new System.Windows.Forms.Label();
|
||||
this.contractNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contractNameLabel
|
||||
//
|
||||
resources.ApplyResources(this.contractNameLabel, "contractNameLabel");
|
||||
this.contractNameLabel.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.contractNameLabel.Name = "contractNameLabel";
|
||||
//
|
||||
// contractNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.contractNameTextBox, "contractNameTextBox");
|
||||
this.contractNameTextBox.Name = "contractNameTextBox";
|
||||
//
|
||||
// ServiceContractDetailViewControl
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.contractNameTextBox);
|
||||
this.Controls.Add(this.contractNameLabel);
|
||||
this.Name = "ServiceContractDetailViewControl";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label contractNameLabel;
|
||||
private System.Windows.Forms.TextBox contractNameTextBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
internal partial class ServiceContractDetailViewControl : ListItemViewControl
|
||||
{
|
||||
|
||||
public ServiceContractDetailViewControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public override event EventHandler ItemChanged;
|
||||
|
||||
public override void UpdateView()
|
||||
{
|
||||
ServiceContractListItem listItem = this.Item as ServiceContractListItem;
|
||||
Fx.Assert(listItem != null, "listItem needs to be a ServiceContractListItem");
|
||||
contractNameTextBox.Text = listItem.Name;
|
||||
contractNameTextBox.Enabled = true;
|
||||
contractNameTextBox.ReadOnly = true;
|
||||
if (listItem.IsCustomContract)
|
||||
{
|
||||
this.contractNameTextBox.ReadOnly = false;
|
||||
this.contractNameTextBox.Validated += new EventHandler(contractNameTextBox_Validated);
|
||||
this.contractNameTextBox.Validating += new CancelEventHandler(contractNameTextBox_Validating);
|
||||
}
|
||||
base.UpdateView();
|
||||
}
|
||||
|
||||
void contractNameTextBox_Validated(object sender, EventArgs e)
|
||||
{
|
||||
ServiceContractListItem contractListItem = (ServiceContractListItem) this.Item;
|
||||
UpdateImplementingActivities(contractListItem);
|
||||
// finally notify other observers of this change
|
||||
if (this.ItemChanged != null)
|
||||
{
|
||||
this.ItemChanged.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void contractNameTextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
ServiceContractListItem contractListItem = (ServiceContractListItem) this.Item;
|
||||
string oldName = contractListItem.Name;
|
||||
contractListItem.Name = this.contractNameTextBox.Text;
|
||||
if (contractListItem.Validating != null)
|
||||
{
|
||||
contractListItem.Validating.Invoke(contractListItem, e);
|
||||
}
|
||||
if (e.Cancel)
|
||||
{
|
||||
this.contractNameTextBox.Text = oldName;
|
||||
contractListItem.Name = oldName;
|
||||
e.Cancel = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void UpdateImplementingActivities(ServiceContractListItem listItem)
|
||||
{
|
||||
foreach (WorkflowServiceOperationListItem workflowOperationListItem in listItem.Operations)
|
||||
{
|
||||
Fx.Assert(workflowOperationListItem != null, "Operations inside an editable contract should only be workflow first operations");
|
||||
workflowOperationListItem.Operation.ContractName = listItem.Name;
|
||||
// update the activities implementing the operation too
|
||||
foreach (Activity activity in workflowOperationListItem.ImplementingActivities)
|
||||
{
|
||||
PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, workflowOperationListItem.Operation.Clone());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime;
|
||||
using System.ServiceModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Workflow.ComponentModel;
|
||||
|
||||
[ListItemView(typeof(ServiceContractViewControl))]
|
||||
[ListItemDetailView(typeof(ServiceContractDetailViewControl))]
|
||||
class ServiceContractListItem : object
|
||||
{
|
||||
ListBox container;
|
||||
Type contractType;
|
||||
bool isCustomContract;
|
||||
ServiceOperationListItem lastItemAdded;
|
||||
string name;
|
||||
ServiceOperationListItemList operations;
|
||||
|
||||
public ServiceContractListItem(ListBox container)
|
||||
{
|
||||
if (container == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("container");
|
||||
}
|
||||
this.operations = new ServiceOperationListItemList();
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public CancelEventHandler Validating;
|
||||
|
||||
public Type ContractType
|
||||
{
|
||||
get { return contractType; }
|
||||
set { contractType = value; }
|
||||
}
|
||||
|
||||
public bool IsCustomContract
|
||||
{
|
||||
get { return isCustomContract; }
|
||||
set { isCustomContract = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public IEnumerable<ServiceOperationListItem> Operations
|
||||
{
|
||||
get { return operations; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void AddOperation(ServiceOperationListItem operation)
|
||||
{
|
||||
if (operation == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
|
||||
}
|
||||
// Dont add operation if operation.Name is broken
|
||||
if (String.IsNullOrEmpty(operation.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ServiceOperationListItem cachedItem = this.operations.Find(operation.Name);
|
||||
if (cachedItem != null)
|
||||
{
|
||||
foreach (Activity activity in operation.ImplementingActivities)
|
||||
{
|
||||
if (!cachedItem.ImplementingActivities.Contains(activity))
|
||||
{
|
||||
cachedItem.ImplementingActivities.Add(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.operations.Add(operation);
|
||||
int positionToAddAt = this.container.Items.IndexOf(this) + 1;
|
||||
if (this.operations.Count > 1)
|
||||
{
|
||||
positionToAddAt = this.container.Items.IndexOf(lastItemAdded) + 1;
|
||||
}
|
||||
lastItemAdded = operation;
|
||||
this.container.Items.Insert(positionToAddAt, operation);
|
||||
}
|
||||
}
|
||||
|
||||
public WorkflowServiceOperationListItem CreateOperation()
|
||||
{
|
||||
WorkflowServiceOperationListItem result = (WorkflowServiceOperationListItem) this.operations.CreateWithUniqueName();
|
||||
result.Operation.ContractName = this.Name;
|
||||
return result;
|
||||
}
|
||||
|
||||
public ServiceOperationListItem Find(string operationName)
|
||||
{
|
||||
Fx.Assert(operationName != null, "operationName != null");
|
||||
return this.operations.Find(operationName);
|
||||
}
|
||||
|
||||
public void SelectionOperation(ServiceOperationListItem operation)
|
||||
{
|
||||
if (operation == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
|
||||
}
|
||||
// Dont select if operation.Name is broken
|
||||
if (String.IsNullOrEmpty(operation.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ServiceOperationListItem operationListItem = this.operations.Find(operation.Name);
|
||||
if (operationListItem != null)
|
||||
{
|
||||
this.container.SetSelected(container.Items.IndexOf(operationListItem), true);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//----------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//----------------------------------------------------------------
|
||||
namespace System.Workflow.Activities.Design
|
||||
{
|
||||
using System.Runtime;
|
||||
using System.ServiceModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
class ServiceContractListItemList : NamedObjectList<ServiceContractListItem>
|
||||
{
|
||||
ListBox container;
|
||||
|
||||
public ServiceContractListItemList(ListBox container)
|
||||
{
|
||||
Fx.Assert(container != null, "Null container passed to ServiceContractListItemList.");
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
protected override string GeneratedNameFormatResource
|
||||
{
|
||||
get
|
||||
{
|
||||
return SR2.GeneratedContractNameFormat;
|
||||
}
|
||||
}
|
||||
|
||||
protected override ServiceContractListItem CreateObject(string name)
|
||||
{
|
||||
ServiceContractListItem result = new ServiceContractListItem(this.container);
|
||||
result.Name = name;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override string GetName(ServiceContractListItem obj)
|
||||
{
|
||||
Fx.Assert(obj != null, "Null object passed to ServiceContractListItemList.GetName()");
|
||||
return obj.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user