当前位置: 首页>>代码示例>>C#>>正文


C# Composite.Display方法代码示例

本文整理汇总了C#中Composite.Display方法的典型用法代码示例。如果您正苦于以下问题:C# Composite.Display方法的具体用法?C# Composite.Display怎么用?C# Composite.Display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composite的用法示例。


在下文中一共展示了Composite.Display方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    /// Entry point into console application.
    static void Main()
    {
        // Create a tree structure
        Composite root = new Composite("root");
        root.Add(new Leaf("Leaf A"));
        root.Add(new Leaf("Leaf B"));

        Composite comp1 = new Composite("Composite X");
        comp1.Add(new Leaf("Leaf XA"));
        comp1.Add(new Leaf("Leaf XB"));
        root.Add(comp1);

        Composite comp2 = new Composite("Composite Y");
        comp2.Add(new Leaf("Leaf YA"));
        comp2.Add(new Leaf("Leaf YB"));
        root.Add(comp2);

        Composite comp3 = new Composite("Composite Z");
        comp3.Add(new Leaf("Leaf ZA"));
        comp3.Add(new Leaf("Leaf ZB"));
        comp2.Add(comp3);

        root.Add(new Leaf("Leaf C"));

        // Add and remove a leaf
        Leaf leaf = new Leaf("Leaf D");
        root.Add(leaf);
        root.Remove(leaf);

        // Recursively display tree
        root.Display(1);

        // Wait for user
        Console.ReadKey();
    }
开发者ID:MikhailJacques,项目名称:Design-Patterns,代码行数:36,代码来源:Composite1.cs

示例2: Main

    private static void Main()
    {
        // Create a tree structure
        Composite root = new Composite("root");
        root.Add(new Leaf("Leaf A"));
        root.Add(new Leaf("Leaf B"));

        Composite comp = new Composite("Composite X");
        comp.Add(new Leaf("Leaf XA"));
        comp.Add(new Leaf("Leaf XB"));

        root.Add(comp);
        root.Add(new Leaf("Leaf C"));

        // Add and remove a leaf
        Leaf leaf = new Leaf("Leaf D");
        root.Add(leaf);
        root.Remove(leaf);

        // Recursively display tree
        root.Display(1);

        // Wait for user
        Console.Read();
    }
开发者ID:darkyto,项目名称:C-Sharp-Stuctural-Design-Patterns,代码行数:25,代码来源:Program.cs

示例3: Main

        public static void Main()
        {
            var root = new Composite("root");
            root.AddChild(new Leaf("Leaf 1"));
            root.AddChild(new Leaf("Leaf 2"));

            var comp = new Composite("Composite C");
            comp.AddChild(new Leaf("Leaf C.1"));
            comp.AddChild(new Leaf("Leaf C.2"));

            root.AddChild(comp);
            root.AddChild(new Leaf("Leaf 3"));

            var leaf = new Leaf("Leaf 4");
            root.AddChild(leaf);
            root.RemoveChild(leaf);

            root.Display(1);
        }
开发者ID:dchakov,项目名称:High-Quality-Code-HomeWork,代码行数:19,代码来源:Program.cs

示例4: Demo

        public static void Demo()
        {
            // Create a tree structure
            Composite root = new Composite("root");
            root.Add(new Leaf("Leaf A"));
            root.Add(new Leaf("Leaf B"));

            Composite comp = new Composite("Composite X");
            comp.Add(new Leaf("Leaf XA"));
            comp.Add(new Leaf("Leaf XB"));

            root.Add(comp);
            root.Add(new Leaf("Leaf C"));

            // Add and remove a leaf
            Leaf leaf = new Leaf("Leaf D");
            root.Add(leaf);
            root.Remove(leaf);

            // Recursively display tree
            root.Display(1);
        }
开发者ID:aloneplayer,项目名称:BenProjects,代码行数:22,代码来源:CompositePattern.cs

示例5: Main

  public static void Main( string[] args )
  {
    // Create a tree structure
    Composite root = new Composite( "root" );
    root.Add( new Leaf( "Leaf A" ));
    root.Add( new Leaf( "Leaf B" ));

    Composite comp = new Composite( "Composite X" );
    comp.Add( new Leaf( "Leaf XA" ) );
    comp.Add( new Leaf( "Leaf XB" ) );

    root.Add( comp );
    root.Add( new Leaf( "Leaf C" ));

    // Add and remove a leaf
    Leaf l = new Leaf( "Leaf D" );
    root.Add( l );
    root.Remove( l );

    // Recursively display nodes
    root.Display( 1 );

  }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:23,代码来源:Composite_Structure.cs

示例6: Composite

            public static void Composite()
            {
                IComponent root = new Composite("root");
                root.Add(new Leaf("Leaf A"));
                root.Add(new Leaf("Leaf B"));
                root.Add(new Leaf("Leaf C"));
                Composite comp = new Composite("Composite X");
                comp.Add(new Leaf("Leaf XA"));
                comp.Add(new Leaf("Leaf XB"));
                comp.Add(new Leaf("Leaf XC"));

                root.Add(comp);
                root.Add(new Leaf("Leaf D"));
                Leaf leaf = new Leaf("Leaf Remove");
                root.Add(leaf);
                root.Remove(leaf);

                root.Display(1);

            }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:20,代码来源:CompositePattern.cs


注:本文中的Composite.Display方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。