protected override void Execute(NativeActivityContext context)
        {
            CorrelationHandle correlationHandle = (this.Correlation == null) ? null : this.Correlation.Get(context);

            if (correlationHandle == null)
            {
                //throw only if ambient correlation handle is also null
                correlationHandle = context.Properties.Find(CorrelationHandle.StaticExecutionPropertyName) as CorrelationHandle;
                if (correlationHandle == null)
                {
                    throw FxTrace.Exception.AsError(
                              new InvalidOperationException(SR2.NullCorrelationHandleInInitializeCorrelation(this.DisplayName)));
                }
            }

            CorrelationExtension extension = context.GetExtension <CorrelationExtension>();

            if (extension != null)
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                foreach (KeyValuePair <string, InArgument <string> > pair in this.CorrelationData)
                {
                    Fx.Assert(pair.Value != null, "pair.Value should be validated during cache metadata");
                    dictionary.Add(pair.Key, pair.Value.Get(context));
                }

                correlationHandle.InitializeBookmarkScope(context, extension.GenerateKey(dictionary));
            }
            else
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.InitializeCorrelationRequiresWorkflowServiceHost(this.DisplayName)));
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            CorrelationHandle handle = (this.Correlation == null) ? null : this.Correlation.Get(context);

            if (handle == null)
            {
                handle = context.Properties.Find(CorrelationHandle.StaticExecutionPropertyName) as CorrelationHandle;
                if (handle == null)
                {
                    throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.NullCorrelationHandleInInitializeCorrelation(base.DisplayName)));
                }
            }
            CorrelationExtension extension = context.GetExtension <CorrelationExtension>();

            if (extension == null)
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.InitializeCorrelationRequiresWorkflowServiceHost(base.DisplayName)));
            }
            Dictionary <string, string> keyData = new Dictionary <string, string>();

            foreach (KeyValuePair <string, InArgument <string> > pair in this.CorrelationData)
            {
                keyData.Add(pair.Key, pair.Value.Get(context));
            }
            handle.InitializeBookmarkScope(context, extension.GenerateKey(keyData));
        }