using Microsoft.Reporting.WebForms; using System; using System.Linq; namespace Vrh.Web.OneReport.ReportViewerForMvc { /// /// ReportExtensions helpers for ReportViewerForMvc /// public static class ReportExtensions { /// /// Set the ReportParameters of the specified ReportParameterInfoCollection. /// /// The Report that this method extends. /// The collection whose ReportParameters should be added to the Report. public static void SetParameters(this Report report, ReportParameterInfoCollection collection) { if (report == null) { throw new ArgumentNullException("report", "Value cannot be null."); } if (collection == null) { throw new ArgumentNullException("collection", "Value cannot be null."); } foreach (ReportParameterInfo reportParameterInfo in collection) { report.SetParameters(reportParameterInfo); } } /// /// Set the ReportParameter of the specified ReportParameterInfo. /// /// The Report that this method extends. /// The ReportParameterInfor whose parameter should be added to the Report. public static void SetParameters(this Report report, ReportParameterInfo reportParameterInfo) { if (report == null) { throw new ArgumentNullException("report", "Value cannot be null."); } if (reportParameterInfo == null) { throw new ArgumentNullException("reportParameterInfo", "Value cannot be null."); } ReportParameter reportParameter = new ReportParameter( reportParameterInfo.Name, reportParameterInfo.Values.ToArray(), reportParameterInfo.Visible); report.SetParameters(reportParameter); } } }