コード例 #1
0
 public void Parse_Error(string input)
 {
     Assert.Throws <FormatException>(() =>
     {
         QosUrlTemplate.Parse(input);
     });
 }
コード例 #2
0
        public void Parse_Success(string input, string expectedMethod, string expectedUrl)
        {
            var template = QosUrlTemplate.Parse(input);

            if (expectedMethod == null)
            {
                Assert.Null(template.HttpMethod);
            }
            else
            {
                Assert.Equal(expectedMethod, template.HttpMethod);
            }
            Assert.Equal(expectedUrl, template.Url);
        }
コード例 #3
0
        private IEnumerable <QosPolicy> BuildPolicies(
            QosQuotaOptions options,
            IEnumerable <IQosPolicyKeyEvaluatorProvider> keyEvaluatorProviders,
            IServiceProvider serviceProvider)
        {
            if (options?.Policies != null)
            {
                foreach (var option in options.Policies)
                {
                    var policy = new QosPolicy(option.Key)
                    {
                        Order        = -1100,
                        UrlTemplates = option.Value.UrlTemplates?.Select(u => QosUrlTemplate.Parse(u)),
                        Key          = keyEvaluatorProviders.Create(option.Value.Key),
                        Gate         = CreateGate(option.Value.Period, option.Value.MaxCount * 1024, option.Value.Distributed, serviceProvider)
                    };

                    yield return(policy);
                }
            }
        }