namespace CSharp.SilverlightDemo.Web
{
    using Telerik.Reporting.Service;
    using Telerik.Reporting;

    public class CustomReportService : ReportService
    {
        //
        static readonly IReportResolver resolvers = new CustomReportResolverWithFallBack(
                                                        new ReportTypeResolver(
                                                            new ReportFileResolver(
                                                             new ReportFileResolverWeb(null))));
        public CustomReportService()
        {
            this.ReportResolver = resolvers;
        }
    }

    class CustomReportResolverWithFallBack : IReportResolver
    {
        readonly IReportResolver parentResolver;

        public CustomReportResolverWithFallBack(IReportResolver parentResolver)
        {
            this.parentResolver = parentResolver;
        }

        public ReportSource Resolve(string report)
        {
            ReportSource reportDocument = this.CustomReportResolver(report);

            if (null == reportDocument
               && null != this.parentResolver)
            {
                reportDocument = this.parentResolver.Resolve(report);
            }

            return reportDocument;
        }

        public ReportSource CustomReportResolver(string report)
        {
            //TODO implement custom report resolving mechanism
            return null;
        }
    }
}