惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
Lohrmann on Cybersecurity
I
Intezer
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
AI
AI
SecWiki News
SecWiki News
C
Cybersecurity and Infrastructure Security Agency CISA
IT之家
IT之家
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
S
Security Affairs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google DeepMind News
Google DeepMind News
H
Hacker News: Front Page
爱范儿
爱范儿
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
V
V2EX
H
Help Net Security
The Hacker News
The Hacker News
G
Google Developers Blog
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
宝玉的分享
宝玉的分享
博客园 - 司徒正美
H
Heimdal Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
S
SegmentFault 最新的问题
C
Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
S
Security @ Cisco Blogs
B
Blog RSS Feed
B
Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone
L
LINUX DO - 最新话题
K
Kaspersky official blog
MongoDB | Blog
MongoDB | Blog

博客园 - YQM

NUnit单元测试属性介绍 C#静态构造函数 没有使用lock的Singleton How to serialize and deserialize using C# .NET - YQM Javascript调用web service 简单的英语不简单 我们应该怎样去学习和工作--写给自己 扩展方法 使用反射-动态创建对象及调用对象方法 使用XmlWriter对象 使用XmlReader类 知道做什么而不是怎样做(摘抄) 生活15点,要记住! 使用javascript动态添加和删除table的行和列 Generate unique strings and numbers in C#(生成一个唯一的字符串和数值) Some notes Localization in ASP.NET 2.0 ASP.NET 2.0: Playing a bit with GridView "Sort Grouping" 通过TryParse来检验和转换数据类型
设计模式之Command模式
YQM · 2008-05-19 · via 博客园 - YQM

namespace DesignPattern
{
    
public interface ILogWriter
    
{
        
void Write(string target, string logValue);
    }

    
public class TxtLogWriter : ILogWriter
    
{
        
ILogWriter Members

    }

    
public class XmlLogWriter : ILogWriter
    
{

        
ILogWriter Members
    }

    
public class DBLogWriter : ILogWriter
    
{

        
ILogWriter Members
    }



    
public class Log
    
{
        
private ILogWriter m_logWriter;
        
public Log(ILogWriter logWriter)
        
{
            m_logWriter 
= logWriter;
        }

        
public void Write(string target, string logValue)
        
{
            m_logWriter.Write(target, logValue);
        }

    }


    
class Program
    
{
        
static void Main(string[] args)
        
{
            Log logTxt 
= new Log(new TxtLogWriter());
            logTxt.Write(
"TxtLogTarget""TxtLogValue");
            Log logXml 
= new Log(new XmlLogWriter());
            logXml.Write(
"XmlLogTarget""XmlLogValue");
            Log logDB 
= new Log(new DBLogWriter());
            logDB.Write(
"DBLogTarget""DBLogValue");
            Console.ReadLine();
        }

    }

}