internal void Uninitialize(Activity activity)
        {
            base.SetValue(PropertiesProperty, null);
            CorrelationTokenEventArgs e = new CorrelationTokenEventArgs(this, false);
            IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> > list = base.GetValue(SubscriptionsProperty) as IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> >;

            if (list != null)
            {
                ActivityExecutorDelegateInfo <CorrelationTokenEventArgs>[] array = new ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> [list.Count];
                list.CopyTo(array, 0);
                foreach (ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> info in array)
                {
                    info.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), e, true, false);
                }
            }
            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken Uninitialized for {0} owner activity {1}", new object[] { this.Name, this.OwnerActivityName });
        }
 public void Initialize(Activity activity, ICollection<CorrelationProperty> propertyValues)
 {
     if (this.Initialized)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.CorrelationAlreadyInitialized, new object[] { this.Name }));
     }
     base.SetValue(PropertiesProperty, propertyValues);
     CorrelationTokenEventArgs e = new CorrelationTokenEventArgs(this, true);
     IList<ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>> list = base.GetValue(SubscriptionsProperty) as IList<ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>>;
     if (list != null)
     {
         foreach (ActivityExecutorDelegateInfo<CorrelationTokenEventArgs> info in list)
         {
             info.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), e, true, false);
         }
     }
     base.SetValue(InitializedProperty, true);
     WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken initialized for {0} owner activity {1} ", new object[] { this.Name, this.OwnerActivityName });
 }
        internal void Uninitialize(Activity activity)
        {
            SetValue(PropertiesProperty, null);

            // fire correlation uninitialized events
            CorrelationTokenEventArgs eventArgs = new CorrelationTokenEventArgs(this, false);
            IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> > subscribers = GetValue(SubscriptionsProperty) as IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> >;

            if (subscribers != null)
            {
                ActivityExecutorDelegateInfo <CorrelationTokenEventArgs>[] clonedSubscribers = new ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> [subscribers.Count];
                subscribers.CopyTo(clonedSubscribers, 0);
                foreach (ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> subscriber in clonedSubscribers)
                {
                    subscriber.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), eventArgs, true, false);
                }
            }
            //SetValue(InitializedProperty, false);
            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken Uninitialized for {0} owner activity {1}", this.Name, this.OwnerActivityName);
        }
        public void Initialize(Activity activity, ICollection <CorrelationProperty> propertyValues)
        {
            if (this.Initialized)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.CorrelationAlreadyInitialized, new object[] { this.Name }));
            }
            base.SetValue(PropertiesProperty, propertyValues);
            CorrelationTokenEventArgs e = new CorrelationTokenEventArgs(this, true);
            IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> > list = base.GetValue(SubscriptionsProperty) as IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> >;

            if (list != null)
            {
                foreach (ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> info in list)
                {
                    info.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), e, true, false);
                }
            }
            base.SetValue(InitializedProperty, true);
            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken initialized for {0} owner activity {1} ", new object[] { this.Name, this.OwnerActivityName });
        }
        public void Initialize(Activity activity, ICollection <CorrelationProperty> propertyValues)
        {
            if (this.Initialized)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, ExecutionStringManager.CorrelationAlreadyInitialized, this.Name));
            }

            SetValue(PropertiesProperty, propertyValues);

            // fire correlation initialized events
            CorrelationTokenEventArgs eventArgs = new CorrelationTokenEventArgs(this, true);
            IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> > subscribers = GetValue(SubscriptionsProperty) as IList <ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> >;

            if (subscribers != null)
            {
                foreach (ActivityExecutorDelegateInfo <CorrelationTokenEventArgs> subscriber in subscribers)
                {
                    subscriber.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), eventArgs, true, false);
                }
            }
            SetValue(InitializedProperty, true);
            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken initialized for {0} owner activity {1} ", this.Name, this.OwnerActivityName);
        }
 internal void Uninitialize(Activity activity)
 {
     base.SetValue(PropertiesProperty, null);
     CorrelationTokenEventArgs e = new CorrelationTokenEventArgs(this, false);
     IList<ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>> list = base.GetValue(SubscriptionsProperty) as IList<ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>>;
     if (list != null)
     {
         ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>[] array = new ActivityExecutorDelegateInfo<CorrelationTokenEventArgs>[list.Count];
         list.CopyTo(array, 0);
         foreach (ActivityExecutorDelegateInfo<CorrelationTokenEventArgs> info in array)
         {
             info.InvokeDelegate(ContextActivityUtils.ContextActivity(activity), e, true, false);
         }
     }
     WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "CorrelationToken Uninitialized for {0} owner activity {1}", new object[] { this.Name, this.OwnerActivityName });
 }