當前位置: 首頁>>代碼示例>>C#>>正文


C# Activity.Save方法代碼示例

本文整理匯總了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;
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:29,代碼來源:WorkflowPersistenceService.cs

示例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()}");
        }
開發者ID:hitesh97,項目名稱:C1-CMS,代碼行數:22,代碼來源:FilePersistenceService.cs

示例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()));
        }
開發者ID:RuneAndersen,項目名稱:C1-CMS,代碼行數:21,代碼來源:FilePersisetenceService.cs


注:本文中的System.Workflow.ComponentModel.Activity.Save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。