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

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
T
Troy Hunt's Blog
GbyAI
GbyAI
H
Hacker News: Front Page
SecWiki News
SecWiki News
V2EX - 技术
V2EX - 技术
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
Hacker News: Ask HN
Hacker News: Ask HN
S
Secure Thoughts
Last Week in AI
Last Week in AI
MyScale Blog
MyScale Blog
L
LINUX DO - 最新话题
C
CERT Recently Published Vulnerability Notes
C
Cyber Attacks, Cyber Crime and Cyber Security
O
OpenAI News
S
SegmentFault 最新的问题
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
美团技术团队
Google DeepMind News
Google DeepMind News
Simon Willison's Weblog
Simon Willison's Weblog
Know Your Adversary
Know Your Adversary
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
S
Securelist
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog RSS Feed
L
Lohrmann on Cybersecurity
Spread Privacy
Spread Privacy
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
The GitHub Blog
The GitHub Blog
B
Blog
F
Fortinet All Blogs
I
InfoQ
C
Check Point Blog
Webroot Blog
Webroot Blog
博客园 - 叶小钗
P
Privacy International News Feed
Latest news
Latest news
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
N
News | PayPal Newsroom

博客园 - 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();
        }

    }

}