FiftyOne.Foundation.Mobile.Detection.Provider.GetMatchingHeaderProfile C# (CSharp) Method

GetMatchingHeaderProfile() private static method

See if any of the headers can be used for this components profile. As soon as one matches then stop and don't look at any more. They are ordered in preferred sequence such that the first item is the most preferred.
private static GetMatchingHeaderProfile ( MatchState state, MatchState>.Dictionary matches, Component component ) : Profile
state MatchState
matches MatchState>.Dictionary
component Component
return Profile
        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;
        }