本文整理匯總了C#中System.Workflow.ComponentModel.Activity.Save方法的典型用法代碼示例。如果您正苦於以下問題:C# Activity.Save方法的具體用法?C# Activity.Save怎麽用?C# Activity.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Workflow.ComponentModel.Activity
的用法示例。
在下文中一共展示了Activity.Save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetDefaultSerializedForm
static protected byte[] GetDefaultSerializedForm(Activity activity)
{
DateTime startTime = DateTime.Now;
Byte[] result;
Debug.Assert(activity != null, "Null activity");
using (MemoryStream stream = new MemoryStream(10240))
{
stream.Position = 0;
activity.Save(stream);
using (MemoryStream compressedStream = new MemoryStream((int)stream.Length))
{
using (GZipStream gzs = new GZipStream(compressedStream, CompressionMode.Compress, true))
{
gzs.Write(stream.GetBuffer(), 0, (int)stream.Length);
}
ActivityExecutionContextInfo executionContextInfo = (ActivityExecutionContextInfo)activity.GetValue(Activity.ActivityExecutionContextInfoProperty);
TimeSpan timeElapsed = DateTime.Now - startTime;
WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0,
"Serialized a {0} with id {1} to length {2}. Took {3}.",
executionContextInfo, executionContextInfo.ContextGuid, compressedStream.Length, timeElapsed);
result = compressedStream.GetBuffer();
Array.Resize<Byte>(ref result, Convert.ToInt32(compressedStream.Length));
}
}
return result;
}
示例2: GetDefaultSerializedForm
protected static byte[] GetDefaultSerializedForm(Activity activity)
{
byte[] buffer;
DateTime now = DateTime.Now;
using (MemoryStream stream = new MemoryStream(0x2800))
{
stream.Position = 0L;
activity.Save(stream);
using (MemoryStream stream2 = new MemoryStream((int) stream.Length))
{
using (GZipStream stream3 = new GZipStream(stream2, CompressionMode.Compress, true))
{
stream3.Write(stream.GetBuffer(), 0, (int) stream.Length);
}
ActivityExecutionContextInfo info = (ActivityExecutionContextInfo) activity.GetValue(Activity.ActivityExecutionContextInfoProperty);
TimeSpan span = (TimeSpan) (DateTime.Now - now);
WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Serialized a {0} with id {1} to length {2}. Took {3}.", new object[] { info, info.ContextGuid, stream2.Length, span });
buffer = stream2.GetBuffer();
Array.Resize<byte>(ref buffer, Convert.ToInt32(stream2.Length));
}
}
return buffer;
}
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:23,代碼來源:WorkflowPersistenceService.cs
示例3: SerializeActivity
private void SerializeActivity(Activity rootActivity, Guid id)
{
if (!ActivityIsSerializable(rootActivity))
{
Log.LogVerbose(LogTitle,
$"The workflow does not support persiting. Id = {id}, Type = {rootActivity.GetType()}");
return;
}
string filename = GetFileName(id);
IFormatter formatter = new BinaryFormatter();
formatter.SurrogateSelector = ActivitySurrogateSelector.Default;
using (C1FileStream stream = new C1FileStream(filename, FileMode.OpenOrCreate))
{
rootActivity.Save(stream, formatter);
stream.Close();
}
// Log.LogVerbose(LogTitle, $"Workflow persisted. Id = {id}, Type = {rootActivity.GetType()}");
}
示例4: SerializeActivity
private void SerializeActivity(Activity rootActivity, Guid id)
{
if (!ActivityIsSerializable(rootActivity))
{
LoggingService.LogVerbose("FileWorkFlowPersisetenceService", string.Format("The workflow does not support persiting. Id = {0}, Type = {1}", id, rootActivity.GetType()));
return;
}
string filename = GetFileName(id);
IFormatter formatter = new BinaryFormatter();
formatter.SurrogateSelector = ActivitySurrogateSelector.Default;
using (C1FileStream stream = new C1FileStream(filename, FileMode.OpenOrCreate))
{
rootActivity.Save(stream, formatter);
stream.Close();
}
// LoggingService.LogVerbose("FileWorkFlowPersisetenceService", string.Format("Workflow persisted. Id = {0}, Type = {1}", id, rootActivity.GetType()));
}