private static Profile GetMatchingHeaderProfile(MatchState state, Dictionary<string, MatchState> matches, Component component)
{
foreach (var header in component.HttpHeaders)
{
MatchState headerMatchState;
if (matches.TryGetValue(header, out headerMatchState) &&
headerMatchState.Signature != null)
{
// Update the statistics about the matching process.
state.SignaturesCompared += headerMatchState.SignaturesCompared;
state.SignaturesRead += headerMatchState.SignaturesRead;
state.StringsRead += headerMatchState.StringsRead;
state.RootNodesEvaluated += headerMatchState.RootNodesEvaluated;
state.NodesEvaluated += headerMatchState.NodesEvaluated;
state.Elapsed += headerMatchState.Elapsed;
state.LowestScore += headerMatchState.LowestScore;
// If the header match used is worst than the current one
// then update the method used for the match returned.
if ((int)headerMatchState.Method > (int)state.Method)
{
state.Method = headerMatchState.Method;
}
// Return the profile for this component.
return headerMatchState.Signature.Profiles.FirstOrDefault(i =>
component.Equals(i.Component));
}
}
return null;
}