コード例 #1
0
        public static void Main(string[] args)
        {
            #region Case One

            var decafWithCaramel = new Caramel(new Decaf());
            Console.WriteLine(decafWithCaramel.Describe());

            var espressoWithSoyAndCaramel = new Caramel(new Soy(new Decaf()));
            Console.WriteLine(espressoWithSoyAndCaramel.Describe());

            #endregion

            #region Case Two

            var windowWithBorderAndVerticalScrollBar =
                new VerticalScrollBarDecorator(new BorderDecorator(new Window {
                Width = 12, Height = 32
            }));
            windowWithBorderAndVerticalScrollBar.Draw();

            var windowWithVerticalAndHorizontalBar =
                new HorizontalScrollBarDecorator(
                    new VerticalScrollBarDecorator(new Window {
                Width = 11, Height = 22
            }));
            windowWithVerticalAndHorizontalBar.Draw();

            #endregion
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: m-daniloff/DesignPatterns
        static void Main(string[] args)
        {
            Window decoratedWindow = new HorizontalScrollBarDecorator(new VerticalScrollBarDecorator(new SimpleWindow()));

            decoratedWindow.Draw();

            Console.WriteLine(decoratedWindow.GetDescription());
        }