本文整理汇总了C#中NativeActivityContext.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# NativeActivityContext.SetValue方法的具体用法?C# NativeActivityContext.SetValue怎么用?C# NativeActivityContext.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeActivityContext
的用法示例。
在下文中一共展示了NativeActivityContext.SetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
protected override void Execute(NativeActivityContext context)
{
var filename = context.GetValue<string>(FileName);
if (!File.Exists(filename))
{
throw new FileNotFoundException(filename);
}
context.SetValue(Extension, Path.GetExtension(filename));
context.SetValue(Directory, Path.GetDirectoryName(filename));
context.SetValue(FileNameWithoutExtension, Path.GetFileNameWithoutExtension(filename));
var fileinfo = new System.IO.FileInfo(filename);
context.SetValue(Created, fileinfo.CreationTime);
context.SetValue(Length, fileinfo.Length);
context.SetValue(IsReadOnly, fileinfo.IsReadOnly);
context.SetValue(Modified, fileinfo.LastWriteTime);
}
示例2: OnOperationCompleted
/// <summary>
/// Respond to the completion callback for the Operation activity.
/// </summary>
/// <param name="context">The activity context.</param>
/// <param name="instance">The current instance of the activity.</param>
/// <param name="result">The result returned by the activity at completion.</param>
private void OnOperationCompleted(NativeActivityContext context, ActivityInstance instance, string result)
{
// Check to see if the operation faulted
if (this.AzureActivityExceptionCaught.Get(context))
{
context.ScheduleActivity(this.Failure);
return;
}
// Store the results of the activity for later
context.SetValue(this.PollingEndTime, DateTime.UtcNow.AddSeconds(this.TimeoutSeconds));
context.SetValue(this.OperationId, result);
// Start the process of polling for status - kind of like a do/while
context.ScheduleFunc(
this.PollingBody,
this.OperationId.Get(context),
this.SubscriptionId.Get(context),
this.CertificateThumbprintId.Get(context),
this.OnGetStatusCompleted,
this.OnOperationFault);
}
示例3: OnReadComplete
void OnReadComplete(NativeActivityContext context, Bookmark bookmark, object state)
{
string input = state as string;
context.SetValue(this.Result, input);
}
示例4: Execute
protected override void Execute(NativeActivityContext context)
{
object obj;
WaitCallback waitCallback;
bool value;
object[] activityInstanceId = new object[1];
activityInstanceId[0] = context.ActivityInstanceId;
this.Tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Beginning execution.", activityInstanceId));
string displayName = base.DisplayName;
if (string.IsNullOrEmpty(displayName))
{
displayName = base.GetType().Name;
}
if (PSActivity._structuredTracer.IsEnabled)
{
PSActivity._structuredTracer.ActivityExecutionStarted(displayName, base.GetType().FullName);
}
PSSQMAPI.IncrementWorkflowActivityPresent(base.GetType().FullName);
bool? activityPersistFlag = this.GetActivityPersistFlag(context);
if (!activityPersistFlag.HasValue || !activityPersistFlag.HasValue)
{
value = false;
}
else
{
value = activityPersistFlag.Value;
}
bool flag = value;
if (!flag)
{
NoPersistHandle noPersistHandle = this.noPersistHandle.Get(context);
noPersistHandle.Enter(context);
}
this.bookmarking.Set(context, flag);
Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
HostParameterDefaults extension = context.GetExtension<HostParameterDefaults>();
if (extension != null)
{
Dictionary<string, object> parameters = extension.Parameters;
foreach (KeyValuePair<string, object> parameter in parameters)
{
strs[parameter.Key] = parameter.Value;
}
if (strs.ContainsKey("PSComputerName") && strs["PSComputerName"] as string != null)
{
object[] item = new object[1];
item[0] = (string)strs["PSComputerName"];
strs["PSComputerName"] = item;
}
}
if (!base.UseDefaultInput && strs.ContainsKey("Input"))
{
strs.Remove("Input");
}
context.SetValue<Dictionary<string, object>>(this.ParameterDefaults, strs);
PSActivityContext pSActivityContext = new PSActivityContext();
pSActivityContext.runningCommands = new Dictionary<PowerShell, RetryCount>();
pSActivityContext.commandQueue = new ConcurrentQueue<ActivityImplementationContext>();
pSActivityContext.IsCanceled = false;
pSActivityContext.HostExtension = extension;
GenericCimCmdletActivity genericCimCmdletActivity = this as GenericCimCmdletActivity;
if (genericCimCmdletActivity != null)
{
pSActivityContext.TypeImplementingCmdlet = genericCimCmdletActivity.TypeImplementingCmdlet;
}
foreach (PSActivityArgumentInfo activityArgument in this.GetActivityArguments())
{
Argument argument = activityArgument.Value;
this.PopulateParameterFromDefault(argument, context, activityArgument.Name, strs);
if (argument.Get(context) == null)
{
continue;
}
object[] name = new object[3];
name[0] = context.ActivityInstanceId;
name[1] = activityArgument.Name;
name[2] = argument.Get(context);
this.Tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "PowerShell activity ID={0}: Using parameter {1}, with value '{2}'.", name));
}
PSDataCollection<PSObject> pSObjects = base.Input.Get(context);
if (pSObjects == null || pSObjects.Count != 0)
{
bool flag1 = false;
PSDataCollection<PSObject> pSObjects1 = base.Result.Get(context);
if (pSObjects1 != null)
{
if (this.GetDisableSerialization(context))
{
pSObjects1.SerializeInput = false;
}
else
{
pSObjects1.SerializeInput = true;
}
}
if ((pSObjects1 == null || !pSObjects1.IsOpen) && base.Result.Expression != null)
{
if (pSObjects1 != null)
{
flag1 = true;
//.........这里部分代码省略.........
示例5: bookmarkCallback
void bookmarkCallback(NativeActivityContext context, Bookmark bookmark, object obj)
{
context.SetValue(returnObjectValue, obj);
}