• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Composite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: UnitTest

	// 
	void UnitTest () {

		// 根節點
		IComponent theRoot = new Composite("Root");
		// 加入兩個最終節點
		theRoot.Add ( new Leaf("Leaf1"));
		theRoot.Add ( new Leaf("Leaf2"));

		// 子節點1
		IComponent theChild1 = new Composite("Child1");
		// 加入兩個最終節點
		theChild1.Add ( new Leaf("Child1.Leaf1"));
		theChild1.Add ( new Leaf("Child1.Leaf2"));
		theRoot.Add (theChild1);

		// 子節點2
		// 加入3個最終節點
		IComponent theChild2 = new Composite("Child2");
		theChild2.Add ( new Leaf("Child2.Leaf1"));
		theChild2.Add ( new Leaf("Child2.Leaf2"));
		theChild2.Add ( new Leaf("Child2.Leaf3"));
		theRoot.Add (theChild2);

		// 顯示
		theRoot.Operation();	


	}
开发者ID:jardar,项目名称:PBaseDefense_Unity3D,代码行数:29,代码来源:CompositeTest.cs


示例2: CreateBehavior

        protected override Composite CreateBehavior()
        {
            return _root ?? (_root =
                new PrioritySelector(
					
                    new Decorator(ret => (me.QuestLog.GetQuestById(14243) != null && me.QuestLog.GetQuestById(14243).IsCompleted),
                        new Sequence(
                            new Action(ret => TreeRoot.StatusText = "Finished!"),
							new Action(ret => Lua.DoString("VehicleExit()")),
							new Action(ret => Thread.Sleep(15000)),
                            new WaitContinue(120,
                            new Action(delegate
                            {
                                _isDone = true;
                                return RunStatus.Success;
                                }))
                            )),
							
					new Decorator(ret => mobList.Count > 0,
                        new Sequence(
                            new Action(ret => TreeRoot.StatusText = "Bombing - " + mobList[0].Name),
							new Action(ret => Lua.DoString("RunMacroText('/click VehicleMenuBarActionButton1','0')")),
							new Action(ret => LegacySpellManager.ClickRemoteLocation(mobList[0].Location)),
                            new Action(ret => Thread.Sleep(2000))
                        )
					)
                )
			);
        }
开发者ID:naacra,项目名称:wowhbbotcracked,代码行数:29,代码来源:14243.cs


示例3: CompositeThrottle

 public CompositeThrottle(TimeSpan throttleTime, Composite composite)
     : base(composite)
 {
     _throttle.WaitTime = throttleTime;
     // _throttle was created with "0" time--this makes it "good to go" 
     // on first visit to CompositeThrottle node
 }
开发者ID:ynyzyfy,项目名称:schorl-scripts,代码行数:7,代码来源:Extensions_TreeSharp.cs


示例4: 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


示例5: 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


示例6: ClipPath

 public ClipPath(double[] xValue, double[] yValue, bool clip, bool fillPath, bool drawPath)
 {
   int num1 = clip ? 1 : 0;
   int num2 = fillPath ? 1 : 0;
   int num3 = drawPath ? 1 : 0;
   base.\u002Ector();
   ClipPath clipPath = this;
   this.xValue = (double[]) null;
   this.yValue = (double[]) null;
   this.clip = true;
   this.drawPath = false;
   this.fillPath = false;
   this.fillPaint = (Paint) null;
   this.drawPaint = (Paint) null;
   this.drawStroke = (Stroke) null;
   this.composite = (Composite) null;
   this.xValue = xValue;
   this.yValue = yValue;
   this.clip = num1 != 0;
   this.fillPath = num2 != 0;
   this.drawPath = num3 != 0;
   this.fillPaint = (Paint) Color.gray;
   this.drawPaint = (Paint) Color.blue;
   this.drawStroke = (Stroke) new BasicStroke(1f);
   this.composite = (Composite) AlphaComposite.Src;
 }
开发者ID:NALSS,项目名称:SmartDashboard.NET,代码行数:26,代码来源:ClipPath.cs


示例7: GMHauntedMines

 public GMHauntedMines(string name, string loadingMatchPath, int[] laneRule, Rectangle minimapRectangle,
     Point leftFountain, Point rightFountain, Composite mapChallengeBehavior, Point leftBasePoint,
     Point rightBasePoint, Point[] topLane, Point[] midLane, Point[] botLane)
     : base(name, loadingMatchPath, laneRule, minimapRectangle, leftFountain, rightFountain, mapChallengeBehavior,
         leftBasePoint, rightBasePoint, topLane, midLane, botLane)
 {
 }
开发者ID:lances101,项目名称:BoringHeroes,代码行数:7,代码来源:GMHauntedMines.cs


示例8: Test

        public static void Test()
        {
            var root = new Composite<Component> { Node = new Component("Component A") };

            root.Add(new Component("Component A - 1"));
            root.Add(new Component("Component A - 2"));
            root.Add(new Component("Component A - 3"));
        }
开发者ID:onurak,项目名称:GOFDesignPatterns,代码行数:8,代码来源:Test.cs


示例9: CreateDeathHandler

 public static Composite CreateDeathHandler(Composite original)
 {
     return
         new PrioritySelector(
             new Action(ret => TrinityDeathSafetyCheck()),
             original
         );
 }
开发者ID:mythsya,项目名称:db-plugins,代码行数:8,代码来源:DeathHandler.cs


示例10: AddChild

 public virtual void AddChild(Composite child)
 {
     if (child != null)
     {
         child.Parent = this;
         this.Children.Add(child);
     }
 }
开发者ID:BibleUs,项目名称:Personality,代码行数:8,代码来源:CompositeGroup.cs


示例11: InsertChild

 public virtual void InsertChild(int index, Composite child)
 {
     if (child != null)
     {
         child.Parent = this;
         this.Children.Insert(index, child);
     }
 }
开发者ID:BibleUs,项目名称:Personality,代码行数:8,代码来源:CompositeGroup.cs


示例12: Tick

        private static void Tick(Composite tree)
        {
            if (tree.LastStatus != RunStatus.Running)
                tree.Start(null);

            if (tree.Tick(null) != RunStatus.Running)
                tree.Stop(null);
        }
开发者ID:ynyzyfy,项目名称:schorl-scripts,代码行数:8,代码来源:Anti+Drown.cs


示例13: CreateLootBehavior

 public static Composite CreateLootBehavior(Composite child)
 {
     return
     new PrioritySelector(
         CreateUseHoradricCache(),
         child
     );
 }
开发者ID:MGramolini,项目名称:Trinity,代码行数:8,代码来源:Composites.cs


示例14: Main

        static void Main(string[] args)
        {
            Composite comp = new Composite();
            comp.Text = "first";
            Leaf leaf = new Leaf();

            comp.add(leaf);
            comp.draw();
        }
开发者ID:janeski,项目名称:DesignPatterns,代码行数:9,代码来源:Program.cs


示例15: LogEntry

 public LogEntry(Composite.Core.Logging.LogEntry fileLogEntry)
 {
     TimeStamp = fileLogEntry.TimeStamp;
     ApplicationDomainId = fileLogEntry.ApplicationDomainId;
     ThreadId = fileLogEntry.ThreadId;
     Severity = fileLogEntry.Severity;
     Title = fileLogEntry.Title;
     DisplayOptions = fileLogEntry.DisplayOptions;
     Message = fileLogEntry.Message;
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:10,代码来源:LogEntry.cs


示例16: Throttle

        /// <summary>
        ///   Creates a 'throttle' composite. This composite limits the number of times the child 
        ///   returns RunStatus.Success within a given time span.  Returns cappedStatus if limit reached, 
        ///   otherwise returns result of child
        /// </summary>
        /// <param name = "limit">max number of occurrences</param>
        /// <param name = "timeFrame">time span for occurrences</param>
        /// <param name="limitStatus">RunStatus to return when limit reached</param>
        /// <param name = "child">composite children to tick (run)</param>
        public Throttle(int limit, TimeSpan timeFrame, RunStatus limitStatus, Composite child)
            : base(child)
        {
            TimeFrame = timeFrame;
            Limit = limit;

            _end = DateTime.MinValue;
            _count = 0;
            _limitStatus = limitStatus;
        }
开发者ID:Asphodan,项目名称:Alphabuddy,代码行数:19,代码来源:Throttle.cs


示例17: GetMessage

 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private static string GetMessage(Composite composite, MethodInfo method, IEnumerable<ConstraintViolation> violations)
 {
     string message = string.Format("{0}.{1} caused parameter constraint violations", composite.GetType().Name, method.Name);
     foreach (ConstraintViolation violation in violations)
     {
         string violationMessage = string.Format("Parameter: '{0}' Value: '{1}' Constraint: '{2}'", violation.Name, violation.Value ?? "{null}", violation.Constraint.GetConstraintName());
         message += Environment.NewLine + violationMessage;
     }
     return message;
 }
开发者ID:attila3453,项目名称:alsing,代码行数:12,代码来源:ParameterConstraintViolationException.cs


示例18: createPartControl

		public override void createPartControl(Composite parent) {
			super.createPartControl(parent);
			
			textInputListener = new TextInputListener(this);
			backgroundCompiler = new BackgroundCompiler(this);
			
			var window = getSite().getWorkbenchWindow();
			partListener = new PartListener(this);
			window.getPartService().addPartListener(partListener);
		}
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:10,代码来源:SourceEditor.stab.cs


示例19: CompositeThrottle

        public CompositeThrottle(TimeSpan throttleTime,
                                 Composite composite)
            : base(composite)
        {
            _hasRunOnce = false;
            _throttle = new Stopwatch();
            _throttleTime = throttleTime;

            _throttle.Reset();
            _throttle.Start();
        }
开发者ID:aussiemob,项目名称:The-Loremaster,代码行数:11,代码来源:WaitForPatrol.cs


示例20: CreateBehavior

 protected override Composite CreateBehavior()
 {
     var children=new Composite[2];
     var compositeArray=new Composite[2];
     compositeArray[0]=new Action(new ActionSucceedDelegate(FlagTagAsCompleted));
     children[0]=new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray));
     ActionDelegate actionDelegateMove=GilesMoveToLocation;
     var sequenceblank=new Sequence(
         new Action(actionDelegateMove)
         );
     children[1]=sequenceblank;
     return new PrioritySelector(children);
 }
开发者ID:BUFORD,项目名称:Funky,代码行数:13,代码来源:TrinityMoveToSNOTag.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompositeDisposable类代码示例发布时间:2022-05-24
下一篇:
C# ComposedType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap