桥接模式在报表系统中的应用

报表系统是信息系统的重要组成部分,在编制报表系统时,我们希望报表生成器与报表的逻辑部分分离,
这样不管采用何种报表 输出技术,业务逻辑部分都可以不受影响,例如在输出报表时,用户经常希望 与ms office 兼容,
将报表输出到ms excel或ms word中而office系统的升级会导致报表系统的升级,
为了提高应用系统的适应性,可以采用桥接模式,降低ms office 软件的升级对系统的影响.

using  System;
using  System.Collections;
using  System.Data;
using  System.Drawing.Drawing2D;
using  System.Drawing;


namespace  ReportBridge
{
    
public interface HReport
    
{
        
void WriteTitle(string title);
        
void WriteAuthor(string author);
        
void WriteHead(ArrayList h);
        
void WriteContent(DataSet ds);
    }
 

    
public interface ReportWriter
    
{
        
void NewReport(string filename);
        
void Write(int col,int row,string cotent,Font f,Color c);
        
void SaveReport();
    }


    
public class Report:HReport
    
{
        
private ReportWriter m_writer;

        
public Report(ReportWriter t_rw)
        
{
            m_writer
=t_rw;
        }



        
HReport 成员

    }



    
public class BMPReportWriter:ReportWriter
    
{
        
ReportWriter 成员

    }


    
public class ExcelReportWriter:ReportWriter
    
{
        
ReportWriter 成员

    }


    
public class Invoker
    
{
        
public void Run()
        
{
            BMPReportWriter m_brw
=new BMPReportWriter();
            HReport m_r
=new Report(m_brw);
            m_r.WriteAuthor(
"myauthor");
             

        }

    }

 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值