コード例 #1
0
        private string DeterminePercentageKey(IClientContext context, List <string> rsiPercentageAttributes)
        {
            if (rsiPercentageAttributes == null || rsiPercentageAttributes.Count == 0)
            {
                return(context.DefaultPercentageKey);
            }

            return(string.Join("$", rsiPercentageAttributes.Select(pa => context.GetAttr(pa, "<none>"))));
        }
コード例 #2
0
        protected bool MatchAttributes(IClientContext context, RolloutStrategy rsi)
        {
            foreach (var attr in rsi.Attributes)
            {
                var suppliedValue = context.GetAttr(attr.FieldName, null);

                if (suppliedValue == null && attr.FieldName.ToLower().Equals("now"))
                {
                    switch (attr.Type)
                    {
                    case RolloutStrategyFieldType.DATE:
                        suppliedValue = LocalDatePattern.Iso.Format(LocalDate.FromDateTime(DateTime.Now));
                        break;

                    case RolloutStrategyFieldType.DATETIME:
                        suppliedValue = LocalDateTimePattern.GeneralIso.Format(LocalDateTime.FromDateTime(DateTime.Now));
                        break;
                    }
                }

                object val = attr.Values;

                if (val == null && suppliedValue == null)
                {
                    if (attr.Conditional != RolloutStrategyAttributeConditional.EQUALS)
                    {
                        return(false);
                    }

                    continue; //skip
                }

                if (val == null || suppliedValue == null)
                {
                    return(false);
                }

                if (!_matcherRepository.FindMatcher(attr).Match(suppliedValue, attr))
                {
                    return(false);
                }
            }

            return(true);
        }