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
0
        internal static Activity ParentContextActivity(Activity activity)
        {
            ActivityExecutionContextInfo info = (ActivityExecutionContextInfo)ContextActivity(activity).GetValue(Activity.ActivityExecutionContextInfoProperty);

            if (info.ParentContextId == -1)
            {
                return(null);
            }
            return(RetrieveWorkflowExecutor(activity).GetContextActivityForId(info.ParentContextId));
        }
Пример #3
0
        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);
        }
 public System.Workflow.ComponentModel.Activity LoadContextActivity(ActivityExecutionContextInfo contextInfo, System.Workflow.ComponentModel.Activity outerContextActivity)
 {
     throw new NotImplementedException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.InteropNonSupportedBehavior, new object[] { this.ServiceProvider.Activity.DisplayName }));
 }
Пример #5
0
 public Activity LoadContextActivity(ActivityExecutionContextInfo contextInfo, Activity outerContextActivity)
 {
     throw new NotImplementedException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.InteropNonSupportedBehavior, this.ServiceProvider.Activity.DisplayName));
 }