本文整理汇总了C#中Activity.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.SetValue方法的具体用法?C# Activity.SetValue怎么用?C# Activity.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTransaction
private void CreateTransaction(Activity atomicActivity)
{
Debug.Assert(this.currentAtomicActivity == null, "There is already a transacted activity running");
TransactionalProperties transactionalProperties = new TransactionalProperties();
TransactionOptions tranOpts = new TransactionOptions();
WorkflowTransactionOptions atomicTxn = TransactedContextFilter.GetTransactionOptions(atomicActivity);
Debug.Assert(atomicTxn != null, "null atomicTxn");
//
tranOpts.IsolationLevel = atomicTxn.IsolationLevel;
if (tranOpts.IsolationLevel == IsolationLevel.Unspecified)
tranOpts.IsolationLevel = IsolationLevel.Serializable;
tranOpts.Timeout = atomicTxn.TimeoutDuration;
// Create a promotable transaction (can be promoted to DTC when necessary)
// as COM+ user code may want to participate in the transaction
// Enlist to the transaction for abort notification
System.Transactions.CommittableTransaction transaction = new CommittableTransaction(tranOpts);
// Can switch back to using TransactionCompletionHandler once VS562627 is fixed
// transaction.TransactionCompleted += new TransactionCompletedEventHandler(TransactionCompletionHandler);
//transaction.EnlistVolatile(new TransactionNotificationEnlistment(this, transaction, atomicActivity), EnlistmentOptions.None);
transactionalProperties.Transaction = transaction;
WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0,
"Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString +
" .Created enlistable transaction " + ((System.Transactions.Transaction)transaction).GetHashCode() +
" with timeout " + tranOpts.Timeout + ", isolation " + tranOpts.IsolationLevel);
// create a local queuing service per atomic context
transactionalProperties.LocalQueuingService = new WorkflowQueuingService(this.qService);
// Store the transaction properties onto the activity
atomicActivity.SetValue(TransactionalPropertiesProperty, transactionalProperties);
// Set current atomic activity
this.currentAtomicActivity = atomicActivity;
atomicActivityEvent = new ManualResetEvent(false);
WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString + " .Set CurrentAtomicActivity to " + atomicActivity.Name);
}
示例2: ProcessDefTag
internal static void ProcessDefTag(WorkflowMarkupSerializationManager serializationManager, XmlReader reader, Activity activity, bool newSegment, string fileName)
{
System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("System.Workflow.ComponentModel.StringResources", typeof(System.Workflow.ComponentModel.ActivityBind).Assembly);
if (reader.NodeType == XmlNodeType.Attribute)
{
switch (reader.LocalName)
{
case StandardXomlKeys.Definitions_Class_LocalName:
activity.SetValue(WorkflowMarkupSerializer.XClassProperty, reader.Value);
break;
default:
serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(CultureInfo.CurrentCulture, resourceManager.GetString("UnknownDefinitionTag"), new object[] { StandardXomlKeys.Definitions_XmlNs_Prefix, reader.LocalName, StandardXomlKeys.Definitions_XmlNs }), (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1, (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1));
break;
}
return;
}
bool exitLoop = false;
bool isEmptyElement = reader.IsEmptyElement;
int initialDepth = reader.Depth;
do
{
XmlNodeType currNodeType = reader.NodeType;
switch (currNodeType)
{
case XmlNodeType.Element:
{
/*
if (!reader.LocalName.Equals(localName))
{
serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(resourceManager.GetString("DefnTagsCannotBeNested"), "def", localName, reader.LocalName), reader.LineNumber, reader.LinePosition));
return;
}
*/
switch (reader.LocalName)
{
case StandardXomlKeys.Definitions_Code_LocalName:
break;
case "Constructor":
default:
serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(CultureInfo.CurrentCulture, resourceManager.GetString("UnknownDefinitionTag"), StandardXomlKeys.Definitions_XmlNs_Prefix, reader.LocalName, StandardXomlKeys.Definitions_XmlNs), (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1, (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1));
return;
}
// if an empty element do a Reader then exit
if (isEmptyElement)
exitLoop = true;
break;
}
case XmlNodeType.EndElement:
{
//reader.Read();
if (reader.Depth == initialDepth)
exitLoop = true;
break;
}
case XmlNodeType.CDATA:
case XmlNodeType.Text:
{
//
int lineNumber = (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1;
int linePosition = (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1;
CodeSnippetTypeMember codeSegment = new CodeSnippetTypeMember(reader.Value);
codeSegment.LinePragma = new CodeLinePragma(fileName, Math.Max(lineNumber - 1, 1));
codeSegment.UserData[UserDataKeys.CodeSegment_New] = newSegment;
codeSegment.UserData[UserDataKeys.CodeSegment_ColumnNumber] = linePosition + reader.Name.Length - 1;
CodeTypeMemberCollection codeSegments = activity.GetValue(WorkflowMarkupSerializer.XCodeProperty) as CodeTypeMemberCollection;
if (codeSegments == null)
{
codeSegments = new CodeTypeMemberCollection();
activity.SetValue(WorkflowMarkupSerializer.XCodeProperty, codeSegments);
}
codeSegments.Add(codeSegment);
//}
/*else
{
serializationManager.ReportError( new WorkflowMarkupSerializationException(
string.Format(resourceManager.GetString("IllegalCDataTextScoping"),
"def",
reader.LocalName,
(currNodeType == XmlNodeType.CDATA ? resourceManager.GetString("CDATASection") : resourceManager.GetString("TextSection"))),
reader.LineNumber,
reader.LinePosition)
);
}
*/
break;
}
}
}
while (!exitLoop && reader.Read());
}