Пример #1
0
        public void CalculateIsSampleActive(TelemetryManifestRule rule, TelemetrySession session)
        {
            IsCalculateCalled = true;
            if (Rate <= 0.0)
            {
                IsSampleActive = false;
                IsRateTooLow   = true;
                return;
            }
            if (Rate >= 1.0)
            {
                IsSampleActive = true;
                IsRateTooHigh  = true;
                return;
            }
            string text = StringExtensions.Join(from t in new Tuple <HashInput, string>[5]
            {
                Tuple.Create(HashInput.MachineId, session.MachineId.ToString()),
                Tuple.Create(HashInput.UserId, session.UserId.ToString()),
                Tuple.Create(HashInput.RuleId, rule.Name),
                Tuple.Create(HashInput.SamplingId, GetFullName(rule)),
                Tuple.Create(HashInput.SessionId, session.SessionId)
            }
                                                where Inputs.Contains(t.Item1)
                                                select t.Item2, ".");

            if (string.IsNullOrEmpty(text))
            {
                IsSampleActive     = false;
                IsInputStringEmpty = true;
                return;
            }
            InputString = text;
            byte[] bytes = Encoding.UTF8.GetBytes(text);
            ulong  num2  = Hash = BitConverter.ToUInt64(FipsCompliantSha.Sha256.ComputeHash(bytes), 0);

            IsSampleActive = ((double)num2 <= Rate * 1.8446744073709552E+19);
        }
Пример #2
0
 public Path(TelemetryManifestRule rule, TelemetryManifestMatchSampling sampling)
 {
     Rule     = rule;
     Sampling = sampling;
 }
Пример #3
0
 public string GetFullName(TelemetryManifestRule rule)
 {
     return(rule.Name + (string.IsNullOrEmpty(Name) ? string.Empty : ("." + Name)));
 }