Skip to main content

ICachedReportSourceWebResolver Interface

Retrieves a CachedReportSourceWeb object associated with the specified report name.

Namespace: DevExpress.XtraReports.Web.WebDocumentViewer

Assembly: DevExpress.XtraReports.v24.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public interface ICachedReportSourceWebResolver

Remarks

When the Web Document Viewer displays a report specified by its name, it can use a ICachedReportSourceWebResolver service to get the CachedReportSourceWeb object that generates a document from a report and caches the document pages.

Implementation

The following code is a custom ICachedReportSourceWebResolver implementation:

public class CustomCachedReportSourceWebResolver : ICachedReportSourceWebResolver {
  public bool TryGetCachedReportSourceWeb(string reportName, out CachedReportSourceWeb CachedReportSourceWeb) {
      XtraReport report = null;
      if(reportName == "Report1") {
          report = new Report1();
      }
      if(reportName == "Report2") {
          report = new Report2();
      }
      if(reportName == "DocumentMerging") {
          var report1 = new Report1();
          var cachedReportSource1 = new CachedReportSourceWeb(report1);
          cachedReportSource1.CreateDocument();

          var report2 = new Report2();
          var cachedReportSource2 = new CachedReportSourceWeb(report2);
          cachedReportSource2.CreateDocument();

          cachedReportSource1.ModifyDocument(x => {
            x.AddPages(cachedReportSource2.PrintingSystem.Pages);
          }
          CachedReportSourceWeb = cachedReportSource1;
          return true;
      }
      if(report == null) {
          CachedReportSourceWeb = null;
          return false;
      }
      CachedReportSourceWeb = new CachedReportSourceWeb(report);
      return true;
  }
} 

Registration

ASP.NET Web Forms and MVC applications
using DevExpress.XtraReports.Web.WebDocumentViewer;
//...
void Application_Start(object sender, EventArgs e) {
    DefaultWebDocumentViewerContainer.Register<ICachedReportSourceWebResolver, CustomCachedReportSourceWebResolver>();
}
ASP.NET Core applications
using DevExpress.XtraReports.Web.WebDocumentViewer;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton<ICachedReportSourceWebResolver>(new CustomCachedReportSourceWebResolver());

var app = builder.Build();

If the TryGetCachedReportSourceWeb(String, out CachedReportSourceWeb) method returns false, the Document Viewer calls the IWebDocumentViewerReportResolver service.

Note

Review the Open a Report in ASP.NET Core Application help topic for more information.

See Also