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);
            }
        }
        internal RTTrackingProfile GetProfile(TrackingService service, Activity workflow, Guid instanceId)
        {
            TrackingProfile profile = service.GetProfile(instanceId);

            if (profile == null)
            {
                return(null);
            }
            return(new RTTrackingProfile(profile, workflow, service.GetType()));
        }
        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);
            }
        }