Esempio n. 1
0
        /// <summary>
        /// Computes the feature.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="message">The message.</param>
        /// <returns>
        /// The active bucket.
        /// </returns>
        public override FeatureBucket ComputeFeature(User user, Message message)
        {
            if (string.IsNullOrEmpty(message.SubjectPrefix))
            {
                return(this.Buckets[0]);
            }

            // FeatureNames[0] is the catch-all bin
            // Note this finds the first matching prefix only.
            foreach (var bucket in Buckets.Skip(1).Take(this.Buckets.Count - 2))
            {
                foreach (string prefix in bucket.Item)
                {
                    if (message.SubjectPrefix == prefix)
                    {
                        return(bucket);
                    }
                }
            }

            return(this.Buckets.Last());
        }