public IValueProvider Handle(IValueProvider provider, Parameter parameter, ParameterValue parameterValue)
 {
     if (parameter.Translator == SerializeStringToValueTranslatorProvider.ProviderKey)
     {
         return new EagerLoadValueProviderDecorator(provider,_settings);
     }
     return provider;
 }
Ejemplo n.º 2
0
        /*[Test]*/
        public void FilterBestMatchWithLotsOfPotentialValues()
        {
            var numParam = new Parameter().FromExpression<SimpleSection, int>(x => x.IntProp);
            foreach (var valueIndex in Enumerable.Range(0, 100))
            {
                var parameterValue = new ParameterValue { Value = valueIndex.ToString() };
                foreach (var refIndex in Enumerable.Range(0, 100))
                {
                    foreach (var subjectIndex in Enumerable.Range(0, 100))
                    {
                        parameterValue.WithTextMatchReference(subjectIndex.ToString(), refIndex.ToString());
                    }
                }
                numParam.AddValue(parameterValue);
            }

            numParam.Values.Add(new ParameterValue { Value = "1" }.WithTextMatchReference("A", "33333").WithTextMatchReference("B", "33333"));

            Section section = new Section().FromType<SimpleSection>()
                                           .AddParameter(numParam);

            IByContext svc = Configure.With(cfg =>
                           cfg.RuntimeContext((context) =>
                           {
                               context.Add("A", "33333");
                               context.Add("B", "33333");
                               foreach (var subjectIndex in Enumerable.Range(0, 100))
                               {
                                   context.Add(subjectIndex.ToString(), "33333" + subjectIndex.ToString());
                               }
                           })
                           .AddSection(section)
                       );

            Trace.Write("start filtering...");
            var stopwatch = Stopwatch.StartNew();
            var simpleSection = svc.GetSection<SimpleSection>();
            stopwatch.Stop();
            Trace.WriteLine("elapsed: " + stopwatch.Elapsed);
            Trace.WriteLine("Milliseconds: " + stopwatch.ElapsedMilliseconds);

            Assert.IsTrue(true);
        }
Ejemplo n.º 3
0
        private ParameterValue BuildParameterValueFromNode(XElement valueNode)
        {
            var parameterValue = new ParameterValue
            {
                Value = valueNode.GetAttributeValueOrThrow(ValueNodeName)
            };

            foreach (XElement conditionNode in valueNode.Elements())
            {
                string name = conditionNode.Name.LocalName;
                Dictionary<string, string> attributes = conditionNode.Attributes()
                                                                     .ToDictionary(x => x.Name.LocalName, x => x.Value);

                parameterValue.FilterConditions.Add(new FilterCondition
                {
                    ConditionName = name,
                    Properties = attributes
                });
            }

            return parameterValue;
        }
Ejemplo n.º 4
0
        private XNode BuildNodeFromValue(ParameterValue value)
        {
            var valueNode = new XElement(ValueNodeName);
            valueNode.SetAttributeValueOrThrow(ValueNodeName, value.Value);
            foreach (FilterCondition condition in value.FilterConditions)
            {
                var conditionNode = new XElement(condition.ConditionName);

                foreach (var property in condition.Properties)
                {
                    conditionNode.SetAttributeValueOrThrow(property.Key, property.Value);
                }
                valueNode.Add(conditionNode);
            }
            return valueNode;
        }