Ejemplo n.º 1
0
        public object Get(IDictionary<string, string> runtimeContext)
        {
            object[] valuesByPolicy = this.Filter.FilterItems(runtimeContext,this.Items).OfType<IValueProvider>().Select(v => v.Get()).ToArray();

            if (!valuesByPolicy.Any())
            {
                if (this.Required)
                {
                    throw new InvalidOperationException(string.Format(
                        "no values selected for parameter {0} using context {1}", this.Name, runtimeContext.FormatString()));
                }
                else
                {
                    return null;
                }
            }

            return this.ResultBuilder.Build(valuesByPolicy);
        }
        public object Get(IDictionary<string, string> runtimeContext)
        {
            object[] valuesByPolicy = this._queryEngine.Query(runtimeContext).Select(p=>p.Get()).ToArray();

            if (!valuesByPolicy.Any())
            {
                if (this.Required)
                {
                    throw new InvalidOperationException(string.Format(
                        "no values selected for parameter {0} using context {1}", this.Name, runtimeContext.FormatString()));
                }
                else
                {
                    return null;
                }
            }

            return this.ResultBuilder.Build(valuesByPolicy);
        }