MultipleTrigger.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Triggers » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Triggers » MultipleTrigger.cs
namespace ThoughtWorks.CruiseControl.Core.Triggers{
    using System;
    using System.Collections;
    using Exortech.NetReflector;
    using ThoughtWorks.CruiseControl.Remote;

    /// <summary>
    /// <para>
    /// The Multiple Trigger is used to support the execution of multiple nested triggers. Each trigger will be executed sequentially in the order specified
    /// in the configuration file. By default, if any of the triggers specify that a build should occur then a build will be triggered. The build condition
    /// will be ForceBuild if any trigger returns a ForceBuild condition. Otherwise, the build condition will be IfModificationsExist if any trigger returns
    /// that condition. Multiple Triggers can contain nested multiple triggers.
    /// </para>
    /// <para>
    /// It is possible to change the logical operator applied to assessing the build conditions. If the Multiple Trigger's operator property is set to "And"
    /// then if any trigger says that a build should not happen, then the build will not happen. This is particularly useful when using multiple <link>Filter
    /// Trigger</link>s.
    /// </para>
    /// <para type="info">
    /// Like all triggers, the multiTrigger must be enclosed within a triggers element in the appropriate <link>Project Configuration Block</link>.
    /// </para>
    /// </summary>
    /// <title>Multiple Trigger</title>
    /// <version>1.0</version>
    /// <example>
    /// <code title="Minimalist example">
    /// &lt;multiTrigger /&gt;
    /// </code>
    /// <code title="Full example">
    /// &lt;multiTrigger operator="And"&gt;
    /// &lt;triggers&gt;
    /// &lt;urlTrigger url="http://server/page.html" seconds="30" buildCondition="ForceBuild"/&gt;
    /// &lt;filterTrigger startTime="23:30" endTime="23:45"&gt;
    /// &lt;trigger type="intervalTrigger" seconds="60" /&gt;
    /// &lt;weekDays&gt;
    /// &lt;weekDay&gt;Sunday&lt;/weekDay&gt;
    /// &lt;/weekDays&gt;
    /// &lt;/filterTrigger&gt;
    /// &lt;/triggers&gt;
    /// &lt;/multiTrigger&gt;    
    /// </code>
    /// </example>
    [ReflectorType("multiTrigger")]
  public class MultipleTrigger : IList, ITrigger
  {
    private ITrigger[] triggers = new ITrigger[0];

        /// <summary>
        /// Initializes a new instance of the <see cref="MultipleTrigger"/> class.
        /// </summary>
        /// <param name="triggers">The triggers.</param>
    public MultipleTrigger(ITrigger[] triggers)
    {
      this.triggers = triggers;
    }

        /// <summary>
        /// Initializes a new instance of the <see cref="MultipleTrigger"/> class.
        /// </summary>
    public MultipleTrigger() : this(new ITrigger[0])
    {}

        /// <summary>
        /// The logical operator to apply to the results of the nested triggers (And or Or).
        /// </summary>
        /// <default>Or</default>
        /// <version>1.1</version>
    [ReflectorProperty("operator", Required=false)]
    public Operator Operator = Operator.Or;

        /// <summary>
        /// The nested triggers.
        /// </summary>
        /// <version>1.0</version>
        /// <default>n/a/</default>
    [ReflectorArray("triggers", Required=false)]
    public ITrigger[] Triggers
    {
      get { return triggers; }
      set { triggers = value; }
    }

    public void IntegrationCompleted()
    {
      foreach (ITrigger trigger in triggers)
      {
        trigger.IntegrationCompleted();
      }
    }

    public DateTime NextBuild
    {
      get
      {
        DateTime earliestDate = DateTime.MaxValue;
        foreach (ITrigger trigger in triggers)
        {
          if (trigger.NextBuild <= earliestDate)
            earliestDate = trigger.NextBuild;
        }
        return earliestDate;
      }
    }

    public IntegrationRequest Fire()
    {
      IntegrationRequest request = null;
      foreach (ITrigger trigger in triggers)
      {
        IntegrationRequest triggerRequest = trigger.Fire();

        if (Operator == Operator.And && triggerRequest == null) return null;

        if (triggerRequest != null)
        {
          if (request == null || triggerRequest.BuildCondition == BuildCondition.ForceBuild)
            request = triggerRequest;
        }
      }
      return request;
    }

    public void CopyTo(Array array, int index)
    {
      throw new NotImplementedException();
    }

    public int Count
    {
      get { throw new NotImplementedException(); }
    }

    public object SyncRoot
    {
      get { throw new NotImplementedException(); }
    }

    public int Add(object value)
    {
      ArrayList t = new ArrayList(triggers);
      t.Add(value);
      triggers = (ITrigger[]) t.ToArray(typeof(ITrigger));
      return triggers.Length;
    }

    public bool Contains(object value)
    {
      throw new NotImplementedException();
    }

    public void Clear()
    {
      throw new NotImplementedException();
    }

    public int IndexOf(object value)
    {
      throw new NotImplementedException();
    }

    public void Insert(int index, object value)
    {
      throw new NotImplementedException();
    }

    public void Remove(object value)
    {
      throw new NotImplementedException();
    }

    public void RemoveAt(int index)
    {
      throw new NotImplementedException();
    }

    public bool IsReadOnly
    {
      get { throw new NotImplementedException(); }
    }

    public bool IsFixedSize
    {
      get { throw new NotImplementedException(); }
    }

    public object this[int index]
    {
      get { throw new NotImplementedException(); }
      set { throw new NotImplementedException(); }
    }

    public bool IsSynchronized
    {
      get { throw new NotImplementedException(); }
    }

    public IEnumerator GetEnumerator()
    {
      return triggers.GetEnumerator();
    }
  }

  public enum Operator
  {
    Or,
    And
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.