private bool AddToCache(RTTrackingProfile profile, Type serviceType, bool resetNoProfiles)
 {
     if (null == serviceType)
     {
         return(false);
     }
     lock (this._cacheLock)
     {
         Dictionary <Type, ProfileList> dictionary = null;
         if (!this._cacheLookup.TryGetValue(serviceType, out dictionary))
         {
             dictionary = new Dictionary <Type, ProfileList>();
             this._cacheLookup.Add(serviceType, dictionary);
         }
         ProfileList list = null;
         if (!dictionary.TryGetValue(profile.WorkflowType, out list))
         {
             list = new ProfileList();
             dictionary.Add(profile.WorkflowType, list);
         }
         if (resetNoProfiles)
         {
             list.NoProfile = false;
         }
         return(list.Profiles.TryAdd(new CacheItem(profile)));
     }
 }
 private bool AddToCache(RTTrackingProfile profile, Type serviceType, bool resetNoProfiles)
 {
     if (null == serviceType)
     {
         return false;
     }
     lock (this._cacheLock)
     {
         Dictionary<Type, ProfileList> dictionary = null;
         if (!this._cacheLookup.TryGetValue(serviceType, out dictionary))
         {
             dictionary = new Dictionary<Type, ProfileList>();
             this._cacheLookup.Add(serviceType, dictionary);
         }
         ProfileList list = null;
         if (!dictionary.TryGetValue(profile.WorkflowType, out list))
         {
             list = new ProfileList();
             dictionary.Add(profile.WorkflowType, list);
         }
         if (resetNoProfiles)
         {
             list.NoProfile = false;
         }
         return list.Profiles.TryAdd(new CacheItem(profile));
     }
 }
 public TrackingChannelWrapper(System.Workflow.Runtime.Tracking.TrackingChannel channel, Type serviceType, Type workflowType, RTTrackingProfile profile)
 {
     this._serviceType      = serviceType;
     this._scheduleType     = workflowType;
     this._channel          = channel;
     this._profile          = profile;
     this._profileVersionId = profile.Version;
 }
 public TrackingChannelWrapper(System.Workflow.Runtime.Tracking.TrackingChannel channel, Type serviceType, Type workflowType, RTTrackingProfile profile)
 {
     this._serviceType = serviceType;
     this._scheduleType = workflowType;
     this._channel = channel;
     this._profile = profile;
     this._profileVersionId = profile.Version;
 }
 internal CacheItem(RTTrackingProfile profile)
 {
     this.LastAccess = DateTime.UtcNow;
     this.VersionId  = new Version(0, 0);
     if (profile == null)
     {
         throw new ArgumentNullException("profile");
     }
     this.ScheduleType    = profile.WorkflowType;
     this.TrackingProfile = profile;
     this.VersionId       = profile.Version;
 }
        internal RTTrackingProfile GetProfile(TrackingService service, Activity schedule)
        {
            if (!this._init)
            {
                throw new ApplicationException(ExecutionStringManager.TrackingProfileManagerNotInitialized);
            }
            if ((service == null) || (schedule == null))
            {
                WorkflowTrace.Tracking.TraceEvent(TraceEventType.Error, 0, ExecutionStringManager.NullParameters);
                return(null);
            }
            Type workflowType         = schedule.GetType();
            RTTrackingProfile profile = null;

            if ((service is IProfileNotification) && this.TryGetFromCache(service.GetType(), workflowType, out profile))
            {
                return(profile);
            }
            TrackingProfile profile2 = null;

            if (!service.TryGetProfile(workflowType, out profile2))
            {
                this.RemoveProfile(workflowType, service.GetType());
                return(null);
            }
            if (this.TryGetFromCache(service.GetType(), workflowType, profile2.Version, out profile))
            {
                return(profile);
            }
            string str = schedule.GetValue(Activity.WorkflowXamlMarkupProperty) as string;

            if ((str != null) && (str.Length > 0))
            {
                return(this.CreateProfile(profile2, schedule, service.GetType()));
            }
            profile = this.CreateProfile(profile2, workflowType, service.GetType());
            lock (this._cacheLock)
            {
                RTTrackingProfile profile3 = null;
                if (this.TryGetFromCache(service.GetType(), workflowType, profile2.Version, out profile3))
                {
                    return(profile3);
                }
                if (!this.AddToCache(profile, service.GetType()))
                {
                    throw new ApplicationException(ExecutionStringManager.ProfileCacheInsertFailure);
                }
                return(profile);
            }
        }
 private RTTrackingProfile(RTTrackingProfile runtimeProfile)
 {
     this._activities            = new Dictionary <string, List <ActivityTrackPointCacheItem> >();
     this._activitiesIgnore      = new List <string>();
     this._user                  = new Dictionary <string, List <UserTrackPoint> >();
     this._userIgnore            = new List <string>();
     this._profile               = runtimeProfile._profile;
     this._isPrivate             = runtimeProfile._isPrivate;
     this._pendingChanges        = runtimeProfile._pendingChanges;
     this._pendingWorkflowChange = runtimeProfile._pendingWorkflowChange;
     this._workflowType          = runtimeProfile._workflowType;
     this._activities            = new Dictionary <string, List <ActivityTrackPointCacheItem> >(runtimeProfile._activities.Count);
     foreach (KeyValuePair <string, List <ActivityTrackPointCacheItem> > pair in runtimeProfile._activities)
     {
         this._activities.Add(pair.Key, runtimeProfile._activities[pair.Key]);
     }
     this._activitiesIgnore = new List <string>(runtimeProfile._activitiesIgnore);
     if (runtimeProfile._dynamicActivities != null)
     {
         this._dynamicActivities = new Dictionary <string, List <ActivityTrackPointCacheItem> >(runtimeProfile._dynamicActivities.Count);
         foreach (KeyValuePair <string, List <ActivityTrackPointCacheItem> > pair2 in runtimeProfile._dynamicActivities)
         {
             this._dynamicActivities.Add(pair2.Key, runtimeProfile._dynamicActivities[pair2.Key]);
         }
     }
     if (runtimeProfile._dynamicActivitiesIgnore != null)
     {
         this._dynamicActivitiesIgnore = new List <string>(runtimeProfile._dynamicActivitiesIgnore);
     }
     this._user = new Dictionary <string, List <UserTrackPoint> >(runtimeProfile._user.Count);
     foreach (KeyValuePair <string, List <UserTrackPoint> > pair3 in runtimeProfile._user)
     {
         this._user.Add(pair3.Key, runtimeProfile._user[pair3.Key]);
     }
     this._userIgnore = new List <string>(runtimeProfile._userIgnore);
     if (runtimeProfile._dynamicUser != null)
     {
         this._dynamicUser = new Dictionary <string, List <UserTrackPoint> >(runtimeProfile._dynamicUser.Count);
         foreach (KeyValuePair <string, List <UserTrackPoint> > pair4 in runtimeProfile._dynamicUser)
         {
             this._dynamicUser.Add(pair4.Key, pair4.Value);
         }
     }
     if (runtimeProfile._dynamicUserIgnore != null)
     {
         this._dynamicUserIgnore = new List <string>(runtimeProfile._dynamicUserIgnore);
     }
 }
 private RTTrackingProfile(RTTrackingProfile runtimeProfile)
 {
     this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>();
     this._activitiesIgnore = new List<string>();
     this._user = new Dictionary<string, List<UserTrackPoint>>();
     this._userIgnore = new List<string>();
     this._profile = runtimeProfile._profile;
     this._isPrivate = runtimeProfile._isPrivate;
     this._pendingChanges = runtimeProfile._pendingChanges;
     this._pendingWorkflowChange = runtimeProfile._pendingWorkflowChange;
     this._workflowType = runtimeProfile._workflowType;
     this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._activities.Count);
     foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> pair in runtimeProfile._activities)
     {
         this._activities.Add(pair.Key, runtimeProfile._activities[pair.Key]);
     }
     this._activitiesIgnore = new List<string>(runtimeProfile._activitiesIgnore);
     if (runtimeProfile._dynamicActivities != null)
     {
         this._dynamicActivities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._dynamicActivities.Count);
         foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> pair2 in runtimeProfile._dynamicActivities)
         {
             this._dynamicActivities.Add(pair2.Key, runtimeProfile._dynamicActivities[pair2.Key]);
         }
     }
     if (runtimeProfile._dynamicActivitiesIgnore != null)
     {
         this._dynamicActivitiesIgnore = new List<string>(runtimeProfile._dynamicActivitiesIgnore);
     }
     this._user = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._user.Count);
     foreach (KeyValuePair<string, List<UserTrackPoint>> pair3 in runtimeProfile._user)
     {
         this._user.Add(pair3.Key, runtimeProfile._user[pair3.Key]);
     }
     this._userIgnore = new List<string>(runtimeProfile._userIgnore);
     if (runtimeProfile._dynamicUser != null)
     {
         this._dynamicUser = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._dynamicUser.Count);
         foreach (KeyValuePair<string, List<UserTrackPoint>> pair4 in runtimeProfile._dynamicUser)
         {
             this._dynamicUser.Add(pair4.Key, pair4.Value);
         }
     }
     if (runtimeProfile._dynamicUserIgnore != null)
     {
         this._dynamicUserIgnore = new List<string>(runtimeProfile._dynamicUserIgnore);
     }
 }
 internal void MakeProfilePrivate(WorkflowExecutor exec)
 {
     if (this._profile != null)
     {
         if (!this._profile.IsPrivate)
         {
             this._profile           = this._profile.Clone();
             this._profile.IsPrivate = true;
         }
     }
     else
     {
         this._profile           = this.GetTrackingProfile(exec).Clone();
         this._profile.IsPrivate = true;
     }
 }
 internal void MakeProfilePrivate(WorkflowExecutor exec)
 {
     if (this._profile != null)
     {
         if (!this._profile.IsPrivate)
         {
             this._profile = this._profile.Clone();
             this._profile.IsPrivate = true;
         }
     }
     else
     {
         this._profile = this.GetTrackingProfile(exec).Clone();
         this._profile.IsPrivate = true;
     }
 }
        internal RTTrackingProfile GetProfile(TrackingService service, Activity workflow, Version versionId)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            if (workflow == null)
            {
                throw new ArgumentNullException("workflow");
            }
            if (!this._init)
            {
                throw new InvalidOperationException(ExecutionStringManager.TrackingProfileManagerNotInitialized);
            }
            Type workflowType         = workflow.GetType();
            RTTrackingProfile profile = null;

            if (this.TryGetFromCache(service.GetType(), workflowType, versionId, out profile))
            {
                return(profile);
            }
            TrackingProfile profile2 = service.GetProfile(workflowType, versionId);
            string          str      = workflow.GetValue(Activity.WorkflowXamlMarkupProperty) as string;

            if ((str != null) && (str.Length > 0))
            {
                return(this.CreateProfile(profile2, workflow, service.GetType()));
            }
            profile = this.CreateProfile(profile2, workflowType, service.GetType());
            lock (this._cacheLock)
            {
                RTTrackingProfile profile3 = null;
                if (this.TryGetFromCache(service.GetType(), workflowType, versionId, out profile3))
                {
                    return(profile3);
                }
                if (!this.AddToCache(profile, service.GetType()))
                {
                    throw new ApplicationException(ExecutionStringManager.ProfileCacheInsertFailure);
                }
                return(profile);
            }
        }
        private void ProfileUpdated(object sender, ProfileUpdatedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            Type serviceType = sender.GetType();

            if (null == e.WorkflowType)
            {
                throw new ArgumentNullException("e");
            }
            if (e.TrackingProfile == null)
            {
                this.RemoveProfile(e.WorkflowType, serviceType);
            }
            else
            {
                RTTrackingProfile profile = this.CreateProfile(e.TrackingProfile, e.WorkflowType, serviceType);
                this.AddToCache(profile, serviceType, true);
            }
        }
        /// <summary>
        /// Constructor used for cloning.
        /// </summary>
        /// <param name="runtimeProfile">RTTrackingProfile to clone</param>
        /// <remarks>All members are shallow copied!  Use MakePrivate to deep copy after cloning.</remarks>
        private RTTrackingProfile(RTTrackingProfile runtimeProfile)
        {
            //
            // Shallow copy
            _profile               = runtimeProfile._profile;
            _isPrivate             = runtimeProfile._isPrivate;
            _pendingChanges        = runtimeProfile._pendingChanges;
            _pendingWorkflowChange = runtimeProfile._pendingWorkflowChange;
            _workflowType          = runtimeProfile._workflowType;
            //
            // Deep copy the cache.  Items in the cache can
            // be shared but the cache themselves cannot as they may be modified
            //
            // Activity match and ignore cache
            _activities = new Dictionary <string, List <ActivityTrackPointCacheItem> >(runtimeProfile._activities.Count);
            foreach (KeyValuePair <string, List <ActivityTrackPointCacheItem> > kvp in runtimeProfile._activities)
            {
                _activities.Add(kvp.Key, runtimeProfile._activities[kvp.Key]);
            }

            _activitiesIgnore = new List <string>(runtimeProfile._activitiesIgnore);
            //
            // Pending dynamic update activity match and ignore cache
            if (null != runtimeProfile._dynamicActivities)
            {
                _dynamicActivities = new Dictionary <string, List <ActivityTrackPointCacheItem> >(runtimeProfile._dynamicActivities.Count);
                foreach (KeyValuePair <string, List <ActivityTrackPointCacheItem> > kvp in runtimeProfile._dynamicActivities)
                {
                    _dynamicActivities.Add(kvp.Key, runtimeProfile._dynamicActivities[kvp.Key]);
                }
            }

            if (null != runtimeProfile._dynamicActivitiesIgnore)
            {
                _dynamicActivitiesIgnore = new List <string>(runtimeProfile._dynamicActivitiesIgnore);
            }
            //
            // User event match and ignore cache
            _user = new Dictionary <string, List <UserTrackPoint> >(runtimeProfile._user.Count);
            foreach (KeyValuePair <string, List <UserTrackPoint> > kvp in runtimeProfile._user)
            {
                _user.Add(kvp.Key, runtimeProfile._user[kvp.Key]);
            }

            _userIgnore = new List <string>(runtimeProfile._userIgnore);
            //
            // Pending dynamic update activity match and ignore cache
            if (null != runtimeProfile._dynamicUser)
            {
                _dynamicUser = new Dictionary <string, List <UserTrackPoint> >(runtimeProfile._dynamicUser.Count);
                foreach (KeyValuePair <string, List <UserTrackPoint> > kvp in runtimeProfile._dynamicUser)
                {
                    _dynamicUser.Add(kvp.Key, kvp.Value);
                }
            }

            if (null != runtimeProfile._dynamicUserIgnore)
            {
                _dynamicUserIgnore = new List <string>(runtimeProfile._dynamicUserIgnore);
            }
        }
 internal void SetTrackingProfile(RTTrackingProfile profile)
 {
     this._profile = profile;
 }
        private bool TryGetFromCache(Type serviceType, Type workflowType, Version versionId, out RTTrackingProfile profile)
        {
            profile = null;
            CacheItem item = null;

            lock (this._cacheLock)
            {
                Dictionary <Type, ProfileList> dictionary = null;
                if (this._cacheLookup.TryGetValue(serviceType, out dictionary))
                {
                    ProfileList list = null;
                    if (!dictionary.TryGetValue(workflowType, out list))
                    {
                        return(false);
                    }
                    if (versionId.Major == 0)
                    {
                        if (!list.NoProfile)
                        {
                            if ((list.Profiles == null) || (list.Profiles.Count == 0))
                            {
                                return(false);
                            }
                            int num = list.Profiles.Count - 1;
                            if (list.Profiles[num] == null)
                            {
                                return(false);
                            }
                            profile = list.Profiles[num].TrackingProfile;
                        }
                        return(true);
                    }
                    if (((list.Profiles != null) && (list.Profiles.Count != 0)) && list.Profiles.TryGetValue(new CacheItem(workflowType, versionId), out item))
                    {
                        profile = item.TrackingProfile;
                        return(true);
                    }
                }
                return(false);
            }
        }
 private bool TryGetFromCache(Type serviceType, Type workflowType, out RTTrackingProfile profile)
 {
     return(this.TryGetFromCache(serviceType, workflowType, new Version(0, 0), out profile));
 }
 private bool AddToCache(RTTrackingProfile profile, Type serviceType)
 {
     return this.AddToCache(profile, serviceType, false);
 }
        private List <TrackingChannelWrapper> GetChannels(Activity schedule, WorkflowExecutor exec, Guid instanceID, Type workflowType, ref TrackingListenerBroker broker)
        {
            if (this._services == null)
            {
                return(null);
            }
            bool flag = false;

            if (broker == null)
            {
                broker = new TrackingListenerBroker();
                flag   = true;
            }
            List <TrackingChannelWrapper> list             = new List <TrackingChannelWrapper>();
            List <string>          callPath                = null;
            Guid                   empty                   = Guid.Empty;
            Guid                   context                 = this.GetContext(exec.RootActivity);
            Guid                   callerContextGuid       = Guid.Empty;
            Guid                   callerParentContextGuid = Guid.Empty;
            TrackingCallingState   trackingCallingState    = exec.TrackingCallingState;
            TrackingListenerBroker broker1                 = (TrackingListenerBroker)exec.RootActivity.GetValue(WorkflowExecutor.TrackingListenerBrokerProperty);
            IList <string>         collection              = (trackingCallingState != null) ? trackingCallingState.CallerActivityPathProxy : null;

            if ((collection != null) && (collection.Count > 0))
            {
                callPath                = new List <string>(collection);
                empty                   = trackingCallingState.CallerWorkflowInstanceId;
                callerContextGuid       = trackingCallingState.CallerContextGuid;
                callerParentContextGuid = trackingCallingState.CallerParentContextGuid;
            }
            TrackingParameters parameters = new TrackingParameters(instanceID, workflowType, exec.WorkflowDefinition, callPath, empty, context, callerContextGuid, callerParentContextGuid);

            for (int i = 0; i < this._services.Count; i++)
            {
                TrackingChannel   trackingChannel     = null;
                Type              trackingServiceType = this._services[i].GetType();
                RTTrackingProfile profile             = null;
                if (flag)
                {
                    profile = this._profileManager.GetProfile(this._services[i], schedule);
                    if (profile == null)
                    {
                        continue;
                    }
                    broker.AddService(trackingServiceType, profile.Version);
                }
                else
                {
                    if (!broker.ContainsService(trackingServiceType))
                    {
                        continue;
                    }
                    if (broker.IsProfileInstance(trackingServiceType))
                    {
                        profile = this._profileManager.GetProfile(this._services[i], schedule, instanceID);
                        if (profile == null)
                        {
                            throw new InvalidOperationException(ExecutionStringManager.MissingProfileForService + trackingServiceType.ToString());
                        }
                        profile.IsPrivate = true;
                    }
                    else
                    {
                        Version version;
                        if (!broker.TryGetProfileVersionId(trackingServiceType, out version))
                        {
                            continue;
                        }
                        profile = this._profileManager.GetProfile(this._services[i], schedule, version);
                        if (profile == null)
                        {
                            throw new InvalidOperationException(ExecutionStringManager.MissingProfileForService + trackingServiceType.ToString() + ExecutionStringManager.MissingProfileForVersion + version.ToString());
                        }
                        if (broker.IsProfilePrivate(trackingServiceType))
                        {
                            profile           = profile.Clone();
                            profile.IsPrivate = true;
                        }
                    }
                }
                trackingChannel = this._services[i].GetTrackingChannel(parameters);
                if (trackingChannel == null)
                {
                    throw new InvalidOperationException(ExecutionStringManager.NullChannel);
                }
                list.Add(new TrackingChannelWrapper(trackingChannel, this._services[i].GetType(), workflowType, profile));
            }
            return(list);
        }
 internal void ReloadProfiles(WorkflowExecutor exec, Guid instanceId, ref TrackingListenerBroker broker, ref List<TrackingChannelWrapper> channels)
 {
     Type workflowType = exec.WorkflowDefinition.GetType();
     foreach (TrackingService service in this._services)
     {
         TrackingProfile profile = null;
         TrackingChannelWrapper wrapper = null;
         if (service.TryReloadProfile(workflowType, instanceId, out profile))
         {
             bool flag = false;
             int index = 0;
             while (index < channels.Count)
             {
                 if (service.GetType() == channels[index].TrackingServiceType)
                 {
                     wrapper = channels[index];
                     flag = true;
                     break;
                 }
                 index++;
             }
             if (profile == null)
             {
                 if (flag)
                 {
                     broker.RemoveService(wrapper.TrackingServiceType);
                     channels.RemoveAt(index);
                 }
             }
             else
             {
                 RTTrackingProfile profile2 = new RTTrackingProfile(profile, exec.WorkflowDefinition, workflowType) {
                     IsPrivate = true
                 };
                 if (!flag)
                 {
                     List<string> callPath = null;
                     Guid empty = Guid.Empty;
                     TrackingCallingState trackingCallingState = exec.TrackingCallingState;
                     IList<string> collection = null;
                     Guid context = this.GetContext(exec.RootActivity);
                     Guid callerContextGuid = Guid.Empty;
                     Guid callerParentContextGuid = Guid.Empty;
                     if (trackingCallingState != null)
                     {
                         collection = trackingCallingState.CallerActivityPathProxy;
                         if ((collection != null) && (collection.Count > 0))
                         {
                             callPath = new List<string>(collection);
                             empty = trackingCallingState.CallerWorkflowInstanceId;
                             callerContextGuid = trackingCallingState.CallerContextGuid;
                             callerParentContextGuid = trackingCallingState.CallerParentContextGuid;
                         }
                     }
                     TrackingParameters parameters = new TrackingParameters(instanceId, workflowType, exec.WorkflowDefinition, callPath, empty, context, callerContextGuid, callerParentContextGuid);
                     TrackingChannelWrapper item = new TrackingChannelWrapper(service.GetTrackingChannel(parameters), service.GetType(), workflowType, profile2);
                     channels.Add(item);
                     Type type = service.GetType();
                     broker.AddService(type, profile2.Version);
                     broker.MakeProfileInstance(type);
                 }
                 else
                 {
                     wrapper.SetTrackingProfile(profile2);
                     broker.MakeProfileInstance(wrapper.TrackingServiceType);
                 }
             }
         }
     }
 }
 internal CacheItem(RTTrackingProfile profile)
 {
     this.LastAccess = DateTime.UtcNow;
     this.VersionId = new Version(0, 0);
     if (profile == null)
     {
         throw new ArgumentNullException("profile");
     }
     this.ScheduleType = profile.WorkflowType;
     this.TrackingProfile = profile;
     this.VersionId = profile.Version;
 }
 private bool TryGetFromCache(Type serviceType, Type workflowType, Version versionId, out RTTrackingProfile profile)
 {
     profile = null;
     CacheItem item = null;
     lock (this._cacheLock)
     {
         Dictionary<Type, ProfileList> dictionary = null;
         if (this._cacheLookup.TryGetValue(serviceType, out dictionary))
         {
             ProfileList list = null;
             if (!dictionary.TryGetValue(workflowType, out list))
             {
                 return false;
             }
             if (versionId.Major == 0)
             {
                 if (!list.NoProfile)
                 {
                     if ((list.Profiles == null) || (list.Profiles.Count == 0))
                     {
                         return false;
                     }
                     int num = list.Profiles.Count - 1;
                     if (list.Profiles[num] == null)
                     {
                         return false;
                     }
                     profile = list.Profiles[num].TrackingProfile;
                 }
                 return true;
             }
             if (((list.Profiles != null) && (list.Profiles.Count != 0)) && list.Profiles.TryGetValue(new CacheItem(workflowType, versionId), out item))
             {
                 profile = item.TrackingProfile;
                 return true;
             }
         }
         return false;
     }
 }
 private bool TryGetFromCache(Type serviceType, Type workflowType, out RTTrackingProfile profile)
 {
     return this.TryGetFromCache(serviceType, workflowType, new Version(0, 0), out profile);
 }
 internal void SetTrackingProfile(RTTrackingProfile profile)
 {
     this._profile = profile;
 }
 private bool AddToCache(RTTrackingProfile profile, Type serviceType)
 {
     return(this.AddToCache(profile, serviceType, false));
 }
        /// <summary>
        /// Constructor used for cloning.  
        /// </summary>
        /// <param name="runtimeProfile">RTTrackingProfile to clone</param>
        /// <remarks>All members are shallow copied!  Use MakePrivate to deep copy after cloning.</remarks>
        private RTTrackingProfile(RTTrackingProfile runtimeProfile)
        {
            //
            // Shallow copy
            _profile = runtimeProfile._profile;
            _isPrivate = runtimeProfile._isPrivate;
            _pendingChanges = runtimeProfile._pendingChanges;
            _pendingWorkflowChange = runtimeProfile._pendingWorkflowChange;
            _workflowType = runtimeProfile._workflowType;
            //
            // Deep copy the cache.  Items in the cache can
            // be shared but the cache themselves cannot as they may be modified
            //
            // Activity match and ignore cache
            _activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._activities.Count);
            foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> kvp in runtimeProfile._activities)
                _activities.Add(kvp.Key, runtimeProfile._activities[kvp.Key]);

            _activitiesIgnore = new List<string>(runtimeProfile._activitiesIgnore);
            //
            // Pending dynamic update activity match and ignore cache
            if (null != runtimeProfile._dynamicActivities)
            {
                _dynamicActivities = new Dictionary<string, List<ActivityTrackPointCacheItem>>(runtimeProfile._dynamicActivities.Count);
                foreach (KeyValuePair<string, List<ActivityTrackPointCacheItem>> kvp in runtimeProfile._dynamicActivities)
                    _dynamicActivities.Add(kvp.Key, runtimeProfile._dynamicActivities[kvp.Key]);
            }

            if (null != runtimeProfile._dynamicActivitiesIgnore)
                _dynamicActivitiesIgnore = new List<string>(runtimeProfile._dynamicActivitiesIgnore);
            //
            // User event match and ignore cache
            _user = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._user.Count);
            foreach (KeyValuePair<string, List<UserTrackPoint>> kvp in runtimeProfile._user)
                _user.Add(kvp.Key, runtimeProfile._user[kvp.Key]);

            _userIgnore = new List<string>(runtimeProfile._userIgnore);
            //
            // Pending dynamic update activity match and ignore cache
            if (null != runtimeProfile._dynamicUser)
            {
                _dynamicUser = new Dictionary<string, List<UserTrackPoint>>(runtimeProfile._dynamicUser.Count);
                foreach (KeyValuePair<string, List<UserTrackPoint>> kvp in runtimeProfile._dynamicUser)
                    _dynamicUser.Add(kvp.Key, kvp.Value);
            }

            if (null != runtimeProfile._dynamicUserIgnore)
                _dynamicUserIgnore = new List<string>(runtimeProfile._dynamicUserIgnore);
        }
        internal void ReloadProfiles(WorkflowExecutor exec, Guid instanceId, ref TrackingListenerBroker broker, ref List <TrackingChannelWrapper> channels)
        {
            Type workflowType = exec.WorkflowDefinition.GetType();

            foreach (TrackingService service in this._services)
            {
                TrackingProfile        profile = null;
                TrackingChannelWrapper wrapper = null;
                if (service.TryReloadProfile(workflowType, instanceId, out profile))
                {
                    bool flag  = false;
                    int  index = 0;
                    while (index < channels.Count)
                    {
                        if (service.GetType() == channels[index].TrackingServiceType)
                        {
                            wrapper = channels[index];
                            flag    = true;
                            break;
                        }
                        index++;
                    }
                    if (profile == null)
                    {
                        if (flag)
                        {
                            broker.RemoveService(wrapper.TrackingServiceType);
                            channels.RemoveAt(index);
                        }
                    }
                    else
                    {
                        RTTrackingProfile profile2 = new RTTrackingProfile(profile, exec.WorkflowDefinition, workflowType)
                        {
                            IsPrivate = true
                        };
                        if (!flag)
                        {
                            List <string>        callPath                = null;
                            Guid                 empty                   = Guid.Empty;
                            TrackingCallingState trackingCallingState    = exec.TrackingCallingState;
                            IList <string>       collection              = null;
                            Guid                 context                 = this.GetContext(exec.RootActivity);
                            Guid                 callerContextGuid       = Guid.Empty;
                            Guid                 callerParentContextGuid = Guid.Empty;
                            if (trackingCallingState != null)
                            {
                                collection = trackingCallingState.CallerActivityPathProxy;
                                if ((collection != null) && (collection.Count > 0))
                                {
                                    callPath                = new List <string>(collection);
                                    empty                   = trackingCallingState.CallerWorkflowInstanceId;
                                    callerContextGuid       = trackingCallingState.CallerContextGuid;
                                    callerParentContextGuid = trackingCallingState.CallerParentContextGuid;
                                }
                            }
                            TrackingParameters     parameters = new TrackingParameters(instanceId, workflowType, exec.WorkflowDefinition, callPath, empty, context, callerContextGuid, callerParentContextGuid);
                            TrackingChannelWrapper item       = new TrackingChannelWrapper(service.GetTrackingChannel(parameters), service.GetType(), workflowType, profile2);
                            channels.Add(item);
                            Type type = service.GetType();
                            broker.AddService(type, profile2.Version);
                            broker.MakeProfileInstance(type);
                        }
                        else
                        {
                            wrapper.SetTrackingProfile(profile2);
                            broker.MakeProfileInstance(wrapper.TrackingServiceType);
                        }
                    }
                }
            }
        }