--- /dev/null
+using System;
+
+namespace mutil {
+
+public interface MessageToolImpl{
+ void send(string message);
+}
+public class MessageTool : MessageToolImpl {
+ // strategy pattern
+ //private messageToolImpl MessageToolImpl = null;
+ public MessageToolImpl MessageToolImpl {private get; set;}
+
+ public void send(string message) {
+ if (MessageToolImpl == null) throw new System.Exception("set MessageToolImpl before sending a message.");
+ MessageToolImpl.send(message);
+ }
+ // singleton
+ static private MessageTool theInstance = null;
+
+ static public MessageTool getInstance() {
+ if (theInstance == null) theInstance = new MessageTool();
+ return theInstance;
+ }
+}
+
+public class ConsoleMessageTool : MessageToolImpl {
+ public void send(string message) {
+ Console.WriteLine(message);
+ }
+}
+
+} // namespace
\ No newline at end of file