private ActivityStateQuery Match(ActivityStateRecord activityStateRecord) { ActivityStateQuery query = null; if (_activitySubscriptions != null) { HybridCollection <ActivityStateQuery> eventSubscriptions; //first look for a specific match, if not found, look for a generic match. if (_activitySubscriptions.TryGetValue(activityStateRecord.Activity.Name, out eventSubscriptions)) { query = MatchActivityState(activityStateRecord, eventSubscriptions.AsReadOnly()); } if (query == null && _activitySubscriptions.TryGetValue("*", out eventSubscriptions)) { query = MatchActivityState(activityStateRecord, eventSubscriptions.AsReadOnly()); if ((query != null) && (_associatedProfile.ImplementationVisibility == ImplementationVisibility.RootScope)) { if (!ShouldTrackActivity(activityStateRecord.Activity, "*")) { return(null); } } } } return(query); }
private void AddActivitySubscription(ActivityStateQuery query) { this.trackingRecordPreFilter.TrackActivityStateRecords = true; foreach (string state in query.States) { if (string.CompareOrdinal(state, "*") == 0) { this.trackingRecordPreFilter.TrackActivityStateRecordsClosedState = true; this.trackingRecordPreFilter.TrackActivityStateRecordsExecutingState = true; break; } if (string.CompareOrdinal(state, ActivityStates.Closed) == 0) { this.trackingRecordPreFilter.TrackActivityStateRecordsClosedState = true; } else if (string.CompareOrdinal(state, ActivityStates.Executing) == 0) { this.trackingRecordPreFilter.TrackActivityStateRecordsExecutingState = true; } } if (this.activitySubscriptions == null) { this.activitySubscriptions = new Dictionary <string, HybridCollection <ActivityStateQuery> >(); } if (!this.activitySubscriptions.TryGetValue(query.ActivityName, out HybridCollection <ActivityStateQuery> subscription)) { subscription = new HybridCollection <ActivityStateQuery>(); this.activitySubscriptions[query.ActivityName] = subscription; } subscription.Add((ActivityStateQuery)query); AddActivityName(query.ActivityName); }
private static ActivityStateQuery MatchActivityState(ActivityStateRecord activityRecord, ReadOnlyCollection <ActivityStateQuery> subscriptions) { ActivityStateQuery genericMatch = null; for (int i = 0; i < subscriptions.Count; i++) { if (subscriptions[i].States.Contains(activityRecord.State)) { return(subscriptions[i]); } else if (subscriptions[i].States.Contains("*")) { if (genericMatch == null) { genericMatch = subscriptions[i]; } } } return(genericMatch); }
private static void ExtractArguments(ActivityStateRecord activityStateRecord, ActivityStateQuery activityStateQuery) { if (activityStateQuery.HasArguments) { activityStateRecord.Arguments = activityStateRecord.GetArguments(activityStateQuery.Arguments); } else { activityStateRecord.Arguments = ActivityUtilities.EmptyParameters; } }
private static void ExtractVariables(ActivityStateRecord activityStateRecord, ActivityStateQuery activityStateQuery) { if (activityStateQuery.HasVariables) { activityStateRecord.Variables = activityStateRecord.GetVariables(activityStateQuery.Variables); } else { activityStateRecord.Variables = ActivityUtilities.EmptyParameters; } }