/// <summary>
 /// Constructs an instance of <see cref="MatchResult"/> based on the
 /// source provided.
 /// </summary>
 /// <param name="source"></param>
 internal MatchResult(MatchState source)
 {
     _elapsed              = source.Elapsed;
     _method               = source.Method;
     _nodesEvaluated       = source.NodesEvaluated;
     _rootNodesEvaluated   = source.RootNodesEvaluated;
     _signature            = source.Signature;
     _signaturesCompared   = source.SignaturesCompared;
     _signaturesRead       = source.SignaturesRead;
     _stringsRead          = source.StringsRead;
     _closestSignatures    = source.ClosestSignatures;
     _lowestScore          = source.LowestScore;
     _targetUserAgent      = source.TargetUserAgent;
     _targetUserAgentArray = source.TargetUserAgentArray;
     _profiles             = (Profile[])source.Profiles.Clone();
     _nodes = source.Nodes.ToArray();
 }
Esempio n. 2
0
 /// <summary>
 /// Creates the state based on the match provided.
 /// </summary>
 /// <param name="match"></param>
 internal MatchState(Match match)
 {
     _elapsed        = match._elapsed;
     _method         = match._method;
     _nodesEvaluated = match._nodesEvaluated;
     _profiles       = new Profile[match.Profiles.Length];
     Array.Copy(match.Profiles, _profiles, _profiles.Length);
     _rootNodesEvaluated   = match._rootNodesEvaluated;
     _signature            = match._signature;
     _signaturesCompared   = match._signaturesCompared;
     _signaturesRead       = match._signaturesRead;
     _stringsRead          = match._stringsRead;
     _closestSignatures    = match._closestSignatures;
     _lowestScore          = match.LowestScore;
     _targetUserAgent      = match.TargetUserAgent;
     _targetUserAgentArray = match.TargetUserAgentArray;
     _nodes = match.Nodes.ToArray();
 }
Esempio n. 3
0
 /// <summary>
 /// Sets the match properties to those provided in the state.
 /// </summary>
 /// <param name="state"></param>
 internal void SetState(MatchState state)
 {
     _elapsed        = state._elapsed;
     _method         = state._method;
     _nodesEvaluated = state._nodesEvaluated;
     _profiles       = new Profile[state._profiles.Length];
     Array.Copy(state._profiles, _profiles, _profiles.Length);
     _rootNodesEvaluated  = state._rootNodesEvaluated;
     _signature           = state._signature;
     _signaturesCompared  = state._signaturesCompared;
     _signaturesRead      = state._signaturesRead;
     _stringsRead         = state._stringsRead;
     _closestSignatures   = state._closestSignatures;
     LowestScore          = state._lowestScore;
     _targetUserAgent     = state._targetUserAgent;
     TargetUserAgentArray = state._targetUserAgentArray;
     Nodes.Clear();
     Nodes.AddRange(state._nodes);
 }
        /// <summary>
        /// Constructs an instance of <see cref="MatchResult"/> based on the
        /// source provided.
        /// </summary>
        /// <param name="source"></param>
        internal MatchResult(MatchState source)
        {
            _dataSet              = source._dataSet;
            _elapsed              = source.Elapsed;
            _method               = source.Method;
            _nodesEvaluated       = source.NodesEvaluated;
            _rootNodesEvaluated   = source.RootNodesEvaluated;
            _signaturesCompared   = source.SignaturesCompared;
            _signaturesRead       = source.SignaturesRead;
            _stringsRead          = source.StringsRead;
            _closestSignatures    = source.ClosestSignatures;
            _lowestScore          = source.LowestScore;
            _targetUserAgent      = source.TargetUserAgent;
            _targetUserAgentArray = source.TargetUserAgentArray;

            if (_dataSet is IndirectDataSet)
            {
                // The match result will only store the index or offset of the
                // related entity type in the source dataset to avoid creating
                // duplicate instances in cases where the data set is an indirect
                // one and a cache, or no cache is being used. This approach
                // ensures a consistent memory profile.
                _signatureIndex = source.Signature != null ?
                                  (int?)source.Signature.Index :
                                  null;
                _profileOffsets = source.Profiles.Select(i => i.Index).ToArray();
                _nodeOffsets    = source.Nodes.Select(i => i.Index).ToArray();
            }
            else
            {
                // The entire data set is being held in memory so a direct
                // reference to the related entity instance can be stored.
                _signature = source.Signature;
                _profiles  = (Profile[])source.Profiles.Clone();
                _nodes     = source.Nodes.ToArray();
            }
        }
Esempio n. 5
0
 public double GetMethodPercentage(MatchMethods method)
 {
     return (double)Methods[method] / (double)Count;
 }
Esempio n. 6
0
 public double GetMethodPercentage(MatchMethods method)
 {
     return((double)Methods[method] / (double)Count);
 }