コード例 #1
0
        public IReportParameterValue DefaultValue(ResolveParameterValue resolver)
        {
            if (reportParameterValues == null)
            {
                throw new ArgumentNullException("resolver", "You must set ReportParameterValues before you can retrieve values!");
            }

            IList <IReportParameterValue> allValidValues = reportParameterValues.GetReportParameterValues(resolver);

            if (allValidValues == null)
            {
                throw new InvalidOperationException("You must set ValidValues before the DefaultValue can be determined");
            }

            if (allValidValues.Count == 0)
            {
                return(null);
            }

            foreach (IReportParameterValue validValue in allValidValues)
            {
                if (validValue.Selected)
                {
                    return(validValue);
                }
            }
            return(allValidValues[0]);
        }
コード例 #2
0
        public IList <IReportParameterValue> ValidValues(ResolveParameterValue resolver)
        {
            if (reportParameterValues == null)
            {
                throw new InvalidOperationException("You must set ReportParameterValues before you can retrieve values!");
            }

            return(reportParameterValues.GetReportParameterValues(resolver));
        }
コード例 #3
0
 public override IList <IReportParameterValue> GetReportParameterValues(ResolveParameterValue resolver)
 {
     return(reportParameterValues);
 }
コード例 #4
0
        public override IList <IReportParameterValue> GetReportParameterValues(ResolveParameterValue resolver)
        {
            List <Type>   argumentTypes = new List <Type>();
            List <object> arguments     = new List <object>();

            foreach (MethodArgumentEntry argument in _methodArguments)
            {
                // also gets moved into get
                Type targetType = argument.type;

                object value = null;

                argumentTypes.Add(targetType);

                switch (argument.source)
                {
                case MethodArgumentSource.Callback:
                    value = resolver(argument.name);
                    break;

                case MethodArgumentSource.Constant:
                    value = argument.value;
                    break;
                }

                arguments.Add(ConversionHelper.Convert(value, targetType));
            }

            object     classInstance = _type.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
            MethodInfo methodInfo    = _type.GetMethod(
                _methodName,
                BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance,
                null,
                argumentTypes.ToArray(),
                new ParameterModifier[0]);

            object result = methodInfo.Invoke(classInstance, arguments.ToArray());

            object[] items = null;

            if (result.GetType().IsArray)
            {
                items = (object[])result;
            }
            else
            {
                foreach (Type t in result.GetType().GetInterfaces())
                {
                    if (t.Equals(typeof(System.Collections.ICollection)))
                    {
                        System.Collections.ICollection c = (System.Collections.ICollection)result;
                        items = new object[c.Count];
                        c.CopyTo(items, 0);
                    }
                    if (t.Equals(typeof(ICollection <object>)))
                    {
                        ICollection <object> c = (ICollection <object>)result;
                        items = new object[c.Count];
                        c.CopyTo(items, 0);
                    }
                }

                if (items == null)
                {
                    items = new object[] { result };
                }
            }

            foreach (object item in items)
            {
                ReportParameterValue reportParameterValue = new ReportParameterValue();
                reportParameterValue.Label = GetPropertyValue(item, _parameterLabelValuePair["Label"]).ToString();
                reportParameterValue.Value = GetPropertyValue(item, _parameterLabelValuePair["Value"]).ToString();
                reportParameterValues.Add(reportParameterValue);
            }
            return(reportParameterValues);
        }
コード例 #5
0
 public abstract IList <IReportParameterValue> GetReportParameterValues(ResolveParameterValue resolver);