using Microsoft.Reporting.WebForms; using System; using System.Linq; namespace Vrh.Web.OneReport.ReportViewerForMvc { /// /// ReportViewerExtensions helpers for ReportViewerForMvc /// public static class ReportViewerExtensions { /// /// Copy the properties of the specified ReportViewer to the ReportViewer. /// /// The ReportViewer that this method extends. /// The ReportViewer whose properties should be copied to the ReportViewer. public static void SetProperties(this ReportViewer reportViewer, ReportViewer properties) { if (reportViewer == null) { throw new ArgumentNullException("reportViewer", "Value cannot be null."); } CopyPropertiesHelper.Copy(ref reportViewer, properties); reportViewer.LocalReport.SetProperties(properties.LocalReport); reportViewer.ServerReport.SetProperties(properties.ServerReport); } /// /// Copy the properties of the specified LocalReport to the LocalReport. /// /// The LocalReport that this method extends. /// The LocalReport whose properties should be copied to the LocalReport. public static void SetProperties(this LocalReport localReport, LocalReport properties) { if (localReport == null) { throw new ArgumentNullException("localReport", "Value cannot be null."); } CopyPropertiesHelper.Copy(ref localReport, properties); localReport.DataSources.Add(properties.DataSources.ToList()); try { localReport.SetParameters(properties.GetParameters()); } catch (MissingReportSourceException) { } //Do nothing } /// /// Copy the properties of the specified ServerReport to the ServerReport. /// /// The ServerReport that this method extends. /// The ServerReport whose properties should be copied to the ServerReport. public static void SetProperties(this ServerReport serverReport, ServerReport properties) { if (serverReport == null) { throw new ArgumentNullException("serverReport", "Value cannot be null."); } CopyPropertiesHelper.Copy(ref serverReport, properties); try { serverReport.SetParameters(properties.GetParameters()); } catch (MissingReportSourceException) { } //Do nothing } } }