本文整理汇总了C#中System.Workflow.ComponentModel.Activity类的典型用法代码示例。如果您正苦于以下问题:C# Activity类的具体用法?C# Activity怎么用?C# Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Activity类属于System.Workflow.ComponentModel命名空间,在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllMembers
internal static void GetAllMembers(Activity activity, IList<TrackingDataItem> items, TrackingAnnotationCollection annotations)
{
Type type = activity.GetType();
foreach (FieldInfo info in type.GetFields(BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance))
{
if (!IsInternalVariable(info.Name))
{
TrackingDataItem item = new TrackingDataItem {
FieldName = info.Name,
Data = GetRuntimeValue(info.GetValue(activity), activity)
};
foreach (string str in annotations)
{
item.Annotations.Add(str);
}
items.Add(item);
}
}
foreach (PropertyInfo info2 in type.GetProperties(BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance))
{
if (!IsInternalVariable(info2.Name) && (info2.GetIndexParameters().Length <= 0))
{
TrackingDataItem item2 = new TrackingDataItem {
FieldName = info2.Name,
Data = GetRuntimeValue(info2.GetValue(activity, null), activity)
};
foreach (string str2 in annotations)
{
item2.Annotations.Add(str2);
}
items.Add(item2);
}
}
}
示例2: InitializeCorrelationTokenCollection
internal static void InitializeCorrelationTokenCollection(Activity activity, CorrelationToken correlator)
{
if ((correlator != null) && !string.IsNullOrEmpty(correlator.OwnerActivityName))
{
string ownerActivityName = correlator.OwnerActivityName;
Activity activityByName = activity.GetActivityByName(ownerActivityName);
if (activityByName == null)
{
activityByName = Helpers.ParseActivityForBind(activity, ownerActivityName);
}
if (activityByName == null)
{
throw new ArgumentException("ownerActivity");
}
CorrelationTokenCollection tokens = activityByName.GetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty) as CorrelationTokenCollection;
if (tokens == null)
{
tokens = new CorrelationTokenCollection();
activityByName.SetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty, tokens);
}
if (!tokens.Contains(correlator.Name))
{
tokens.Add(correlator);
}
}
}
示例3: WalkerEventArgs
internal WalkerEventArgs(Activity currentActivity, object currentValue, PropertyInfo currentProperty, object currentPropertyOwner)
: this(currentActivity)
{
this.currentPropertyOwner = currentPropertyOwner;
this.currentProperty = currentProperty;
this.currentValue = currentValue;
}
示例4: Initialize
protected override void Initialize(Activity activity)
{
base.Initialize(activity);
HelpText = DR.GetString(DR.SequentialWorkflowHelpText);
Header.Text = DR.GetString(DR.StartSequentialWorkflow);
}
示例5: ApplyTo
protected override bool ApplyTo(Activity rootActivity)
{
if (rootActivity == null)
{
return false;
}
RuleDefinitions definitions = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
if (definitions == null)
{
definitions = new RuleDefinitions();
rootActivity.SetValue(RuleDefinitions.RuleDefinitionsProperty, definitions);
}
bool flag = false;
if (definitions.Conditions.RuntimeMode)
{
definitions.Conditions.RuntimeMode = false;
flag = true;
}
try
{
definitions.Conditions.Add(this.ConditionDefinition);
}
finally
{
if (flag)
{
definitions.Conditions.RuntimeMode = true;
}
}
return true;
}
示例6: ApplyTo
protected override bool ApplyTo(Activity rootActivity)
{
if (rootActivity == null)
{
return false;
}
RuleDefinitions definitions = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
if ((definitions == null) || (definitions.RuleSets == null))
{
return false;
}
if (definitions.RuleSets[this.RuleSetName] == null)
{
return false;
}
bool flag = false;
if (definitions.Conditions.RuntimeMode)
{
definitions.Conditions.RuntimeMode = false;
flag = true;
}
try
{
definitions.RuleSets.Remove(this.RuleSetName);
definitions.RuleSets.Add(this.updated);
}
finally
{
if (flag)
{
definitions.RuleSets.RuntimeMode = true;
}
}
return true;
}
示例7: CreateTypeProvider
protected static TypeProvider CreateTypeProvider(Activity rootActivity)
{
TypeProvider typeProvider = new TypeProvider(null);
Type companionType = rootActivity.GetType();
typeProvider.SetLocalAssembly(companionType.Assembly);
typeProvider.AddAssembly(companionType.Assembly);
foreach (AssemblyName assemblyName in companionType.Assembly.GetReferencedAssemblies())
{
Assembly referencedAssembly = null;
try
{
referencedAssembly = Assembly.Load(assemblyName);
if (referencedAssembly != null)
{
typeProvider.AddAssembly(referencedAssembly);
}
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
}
if (referencedAssembly == null && assemblyName.CodeBase != null)
{
typeProvider.AddAssemblyReference(assemblyName.CodeBase);
}
}
return typeProvider;
}
示例8: SaveWorkflowInstanceState
// Save the workflow instance state at the point of persistence with option of locking the instance state if it is shared
// across multiple runtimes or multiple phase instance updates
protected override void SaveWorkflowInstanceState(Activity rootActivity, bool unlock)
{
// Save the workflow
Guid contextGuid = (Guid)rootActivity.GetValue(Activity.ActivityContextGuidProperty);
Console.WriteLine("Saving instance: {0}\n", contextGuid);
SerializeToFile(
WorkflowPersistenceService.GetDefaultSerializedForm(rootActivity), contextGuid);
// See when the next timer (Delay activity) for this workflow will expire
TimerEventSubscriptionCollection timers = (TimerEventSubscriptionCollection)rootActivity.GetValue(TimerEventSubscriptionCollection.TimerCollectionProperty);
TimerEventSubscription subscription = timers.Peek();
if (subscription != null)
{
// Set a system timer to automatically reload this workflow when its next timer expires
TimerCallback callback = new TimerCallback(ReloadWorkflow);
TimeSpan timeDifference = subscription.ExpiresAt - DateTime.UtcNow;
// check to make sure timeDifference is in legal range
if (timeDifference > FilePersistenceService.MaxInterval)
{
timeDifference = FilePersistenceService.MaxInterval;
}
else if (timeDifference < TimeSpan.Zero)
{
timeDifference = TimeSpan.Zero;
}
this.instanceTimers.Add(contextGuid, new System.Threading.Timer(
callback,
subscription.WorkflowInstanceId,
timeDifference,
new TimeSpan(-1)));
}
}
示例9: RuleSetDialog
public RuleSetDialog(Activity activity, RuleSet ruleSet)
{
if (activity == null)
throw (new ArgumentNullException("activity"));
InitializeDialog(ruleSet);
ITypeProvider typeProvider;
this.serviceProvider = activity.Site;
if (this.serviceProvider != null)
{
typeProvider = (ITypeProvider)this.serviceProvider.GetService(typeof(ITypeProvider));
if (typeProvider == null)
{
string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ITypeProvider).FullName);
throw new InvalidOperationException(message);
}
WorkflowDesignerLoader loader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
if (loader != null)
loader.Flush();
}
else
{
// no service provider, so make a TypeProvider that has all loaded Assemblies
TypeProvider newProvider = new TypeProvider(null);
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
newProvider.AddAssembly(a);
typeProvider = newProvider;
}
RuleValidation validation = new RuleValidation(activity, typeProvider, false);
this.ruleParser = new Parser(validation);
}
示例10: WorkflowCompletedEventArgs
internal WorkflowCompletedEventArgs(WorkflowInstance instance, Activity workflowDefinition)
: base(instance)
{
this._outputParameters = new Dictionary<String, Object>();
this._originalWorkflowDefinition = workflowDefinition;
this._workflowDefinition = null;
}
示例11: ApplyTo
protected internal override bool ApplyTo(Activity rootActivity)
{
if (rootActivity == null)
{
throw new ArgumentNullException("rootActivity");
}
if (!(rootActivity is CompositeActivity))
{
throw new ArgumentException(SR.GetString("Error_RootActivityTypeInvalid"), "rootActivity");
}
CompositeActivity activity = rootActivity.TraverseDottedPathFromRoot(base.OwnerActivityDottedPath) as CompositeActivity;
if (activity == null)
{
return false;
}
if (this.removedActivityIndex >= activity.Activities.Count)
{
return false;
}
activity.DynamicUpdateMode = true;
try
{
this.originalRemovedActivity = activity.Activities[this.removedActivityIndex];
activity.Activities.RemoveAt(this.removedActivityIndex);
}
finally
{
activity.DynamicUpdateMode = false;
}
return true;
}
示例12: Evaluate
// Methods
public override bool Evaluate (Activity activity, IServiceProvider provider)
{
Activity parent = activity;
RuleDefinitions definitions = null;
while (parent != null) {
definitions = (RuleDefinitions) parent.GetValue (RuleDefinitions.RuleDefinitionsProperty);
if (definitions != null)
break;
parent = parent.Parent;
}
if (definitions == null) {
Console.WriteLine ("No definition");
return false;
}
//Console.WriteLine ("Definition {0} at {1}", definitions, parent);
RuleValidation validation = new RuleValidation (activity.GetType (), null);
RuleExecution execution = new RuleExecution (validation, parent);
RuleCondition condition = definitions.Conditions [ConditionName];
//Console.WriteLine ("Condition {0}", condition);
return condition.Evaluate (execution);
}
示例13: FilterDependencyProperties
internal static void FilterDependencyProperties(IServiceProvider serviceProvider, Activity activity)
{
IExtenderListService service = serviceProvider.GetService(typeof(IExtenderListService)) as IExtenderListService;
if (service != null)
{
Dictionary<string, DependencyProperty> dictionary = new Dictionary<string, DependencyProperty>();
foreach (DependencyProperty property in activity.MetaDependencyProperties)
{
dictionary.Add(property.Name, property);
}
List<string> list = new List<string>();
foreach (IExtenderProvider provider in service.GetExtenderProviders())
{
if (!provider.CanExtend(activity))
{
ProvidePropertyAttribute[] customAttributes = provider.GetType().GetCustomAttributes(typeof(ProvidePropertyAttribute), true) as ProvidePropertyAttribute[];
foreach (ProvidePropertyAttribute attribute in customAttributes)
{
list.Add(attribute.PropertyName);
}
}
}
foreach (string str in list)
{
if (dictionary.ContainsKey(str))
{
activity.RemoveProperty(dictionary[str]);
}
}
}
}
示例14: AddActivityToDesigner
public void AddActivityToDesigner(Activity activity)
{
if (activity == null)
{
throw new ArgumentNullException("activity");
}
IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (service == null)
{
throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IDesignerHost).FullName }));
}
if ((activity.Parent == null) && (service.RootComponent == null))
{
string str = activity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
string name = !string.IsNullOrEmpty(str) ? Helpers.GetClassName(str) : Helpers.GetClassName(activity.GetType().FullName);
service.Container.Add(activity, name);
this.AddTargetFrameworkProvider(activity);
}
else
{
service.Container.Add(activity, activity.QualifiedName);
this.AddTargetFrameworkProvider(activity);
}
if (activity is CompositeActivity)
{
foreach (Activity activity2 in Helpers.GetNestedActivities(activity as CompositeActivity))
{
service.Container.Add(activity2, activity2.QualifiedName);
this.AddTargetFrameworkProvider(activity2);
}
}
}
示例15: ApplyDynamicUpdateMode
private void ApplyDynamicUpdateMode(Activity seedActivity)
{
Queue<Activity> queue = new Queue<Activity>();
queue.Enqueue(seedActivity);
while (queue.Count > 0)
{
Activity activity = queue.Dequeue();
activity.Readonly = true;
activity.DynamicUpdateMode = true;
foreach (DependencyProperty property in activity.MetaDependencyProperties)
{
if (activity.IsBindingSet(property))
{
ActivityBind binding = activity.GetBinding(property);
if (binding != null)
{
binding.DynamicUpdateMode = true;
}
}
}
if (activity is CompositeActivity)
{
CompositeActivity activity2 = activity as CompositeActivity;
activity2.Activities.ListChanged += new EventHandler<ActivityCollectionChangeEventArgs>(this.OnActivityListChanged);
foreach (Activity activity3 in ((CompositeActivity) activity).Activities)
{
queue.Enqueue(activity3);
}
}
}
}