本文整理汇总了C#中NativeActivityContext类的典型用法代码示例。如果您正苦于以下问题:C# NativeActivityContext类的具体用法?C# NativeActivityContext怎么用?C# NativeActivityContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NativeActivityContext类属于命名空间,在下文中一共展示了NativeActivityContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalExecute
void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance)
{
CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>();
if (compensationExtension == null)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ConfirmWithoutCompensableActivity(this.DisplayName)));
}
CompensationToken token = Target.Get(context);
CompensationTokenData tokenData = token == null ? null : compensationExtension.Get(token.CompensationId);
Fx.Assert(tokenData != null, "CompensationTokenData must be valid");
if (tokenData.ExecutionTracker.Count > 0)
{
if (this.onChildConfirmed == null)
{
this.onChildConfirmed = new CompletionCallback(InternalExecute);
}
this.toConfirmToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get()));
Fx.Assert(Body != null, "Body must be valid");
context.ScheduleActivity(Body, this.onChildConfirmed);
}
}
示例2: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark(
this.BookmarkName.Get(context),
(activityContext, bookmark, value) =>
activityContext.ResumeBookmark(new Bookmark(this.BookmarkName.Get(activityContext)), null));
}
示例3: OnExecuteBodyCompleted
private void OnExecuteBodyCompleted(NativeActivityContext context, ActivityInstance instance)
{
var vars = ComputationContext.GetVariables(context, this);
vars.Set(IterationNoVarName, vars.Get<int>(IterationNoVarName) + 1);
context.ScheduleActivity(Condition, OnExecuteConditionCompleted);
}
示例4: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Path.Expression != null)
{
targetCommand.AddParameter("Path", Path.Get(context));
}
if(LiteralPath.Expression != null)
{
targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
}
if(IncludeTotalCount.Expression != null)
{
targetCommand.AddParameter("IncludeTotalCount", IncludeTotalCount.Get(context));
}
if(Skip.Expression != null)
{
targetCommand.AddParameter("Skip", Skip.Get(context));
}
if(First.Expression != null)
{
targetCommand.AddParameter("First", First.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例5: Execute
protected override void Execute(NativeActivityContext context)
{
if (this.Activities.Count > 0)
{
Bookmark bm = context.Properties.Find(Constants._ContainsChildWizard) as Bookmark;
if (bm != null)
{
context.ResumeBookmark(bm, true);
}
Bookmark parentbm = context.Properties.Find(Constants._ResumeParent) as Bookmark;
if (parentbm != null)
{
this.ResumeParent.Set(context, parentbm);
}
Bookmark ResumeParent = context.CreateBookmark(ResumeParentCallBack, BookmarkOptions.NonBlocking | BookmarkOptions.MultipleResume);
context.Properties.Update(Constants._ResumeParent, ResumeParent);
FindStepAndSchedule(context);
}
}
示例6: GetVariables
public static GenericVariableCollection GetVariables(NativeActivityContext context, Activity activity)
{
Contract.Requires(context != null);
Contract.Requires(activity != null);
return GetVariables(context, activity.Id);
}
示例7: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Name.Expression != null)
{
targetCommand.AddParameter("Name", Name.Get(context));
}
if(Force.Expression != null)
{
targetCommand.AddParameter("Force", Force.Get(context));
}
if(SecurityDescriptorSddl.Expression != null)
{
targetCommand.AddParameter("SecurityDescriptorSddl", SecurityDescriptorSddl.Get(context));
}
if(SkipNetworkProfileCheck.Expression != null)
{
targetCommand.AddParameter("SkipNetworkProfileCheck", SkipNetworkProfileCheck.Get(context));
}
if(NoServiceRestart.Expression != null)
{
targetCommand.AddParameter("NoServiceRestart", NoServiceRestart.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例8: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(HotFixId.Expression != null)
{
targetCommand.AddParameter("Id", HotFixId.Get(context));
}
if(Description.Expression != null)
{
targetCommand.AddParameter("Description", Description.Get(context));
}
if(Credential.Expression != null)
{
targetCommand.AddParameter("Credential", Credential.Get(context));
}
if(GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
{
targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例9: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Date.Expression != null)
{
targetCommand.AddParameter("Date", Date.Get(context));
}
if(Adjust.Expression != null)
{
targetCommand.AddParameter("Adjust", Adjust.Get(context));
}
if(DisplayHint.Expression != null)
{
targetCommand.AddParameter("DisplayHint", DisplayHint.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例10: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(SourceIdentifier.Expression != null)
{
targetCommand.AddParameter("SourceIdentifier", SourceIdentifier.Get(context));
}
if(Sender.Expression != null)
{
targetCommand.AddParameter("Sender", Sender.Get(context));
}
if(EventArguments.Expression != null)
{
targetCommand.AddParameter("EventArguments", EventArguments.Get(context));
}
if(MessageData.Expression != null)
{
targetCommand.AddParameter("MessageData", MessageData.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例11: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(PSProvider.Expression != null)
{
targetCommand.AddParameter("PSProvider", PSProvider.Get(context));
}
if(PSDrive.Expression != null)
{
targetCommand.AddParameter("PSDrive", PSDrive.Get(context));
}
if(Stack.Expression != null)
{
targetCommand.AddParameter("Stack", Stack.Get(context));
}
if(StackName.Expression != null)
{
targetCommand.AddParameter("StackName", StackName.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例12: Cancel
protected override void Cancel(NativeActivityContext context)
{
Bookmark bookmark = this.timerBookmark.Get(context);
this.GetTimerExtension(context).CancelTimer(bookmark);
context.RemoveBookmark(bookmark);
context.MarkCanceled();
}
示例13: GetPowerShell
// Module defining this command
// Optional custom code for this activity
/// <summary>
/// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
/// </summary>
/// <param name="context">The NativeActivityContext for the currently running activity.</param>
/// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
/// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
{
System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create();
System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);
// Initialize the arguments
if(Path.Expression != null)
{
targetCommand.AddParameter("Path", Path.Get(context));
}
if(ChildPath.Expression != null)
{
targetCommand.AddParameter("ChildPath", ChildPath.Get(context));
}
if(Resolve.Expression != null)
{
targetCommand.AddParameter("Resolve", Resolve.Get(context));
}
if(Credential.Expression != null)
{
targetCommand.AddParameter("Credential", Credential.Get(context));
}
return new ActivityImplementationContext() { PowerShellInstance = invoker };
}
示例14: Execute
protected override void Execute(NativeActivityContext context)
{
if (this.Body != null)
{
context.ScheduleActivity(this.Body, new CompletionCallback(OnBodyComplete));
}
}
示例15: OnExecute
protected override void OnExecute(NativeActivityContext context, object objectToValidate, ValidationContext objectToValidateContext)
{
bool foundMultiple;
ActivityWithResult boundExpression;
LocationReference locationReference;
ActivityWithResult activity = (ActivityWithResult)objectToValidate;
foreach (RuntimeArgument runtimeArgument in activity.RuntimeArguments)
{
boundExpression = runtimeArgument.BoundArgument.Expression;
if (boundExpression != null && boundExpression is ILocationReferenceWrapper)
{
locationReference = ((ILocationReferenceWrapper)boundExpression).LocationReference;
if (locationReference != null)
{
foundMultiple = FindLocationReferencesFromEnvironment(objectToValidateContext.Environment, locationReference.Name);
if (foundMultiple)
{
Constraint.AddValidationError(context, new ValidationError(SR.AmbiguousVBVariableReference(locationReference.Name)));
}
}
}
}
}