mockobjects.cs

来自「.NET 2.0模式开发实战源代码,使用C#说明」· CS 代码 · 共 40 行

CS
40
字号
using com.devspace.commons.Tracer;namespace Chap03MockObjects {    public delegate void FeedbackString( string message);    class NoCallbackDefinedException : ApplicationFatalException {        public NoCallbackDefinedException() : base( "No callback is defined") {        }        public static System.Exception Instantiate() {            return new NoCallbackDefinedException();        }    }    public class Callback {        private static FeedbackString _feedback;        public static FeedbackString CBFeedbackString {            get {                if( _feedback == null) {                    throw new NoCallbackDefinedException();                }                return _feedback;            }            set {                _feedback = value;            }        }    }    public class Console {        public Console() {        }        public static void WriteLine( string message) {            Callback.CBFeedbackString( message);        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?