|
using System;
using System.Collections.Generic;
namespace SimpleRulesEngine.Trigger
{
public class Or : ConditionBase
{
#region ctor
/// <summary>
/// Initializes a new instance of the <see cref="OrCondition"/> class.
/// </summary>
/// <param name="conditions">The conditions.</param>
public Or(List<ConditionBase> conditions)
{
this.conditions = conditions;
}
#endregion
#region private fields
/// <summary>
/// Conditions
/// </summary>
private List<ConditionBase> conditions;
/// <summary>
/// Trigger call back
/// </summary>
private Trigger trigger;
#endregion
#region methods
/// <summary>
/// Determines whether [is condition satisfied].
/// </summary>
/// <returns>
/// <c>true</c> if [is condition satisfied]; otherwise, <c>false</c>.
/// </returns>
public override bool IsConditionSatisfied()
{
bool blnIsConditionSatisfied = false;
foreach (ConditionBase condition in conditions)
{
blnIsConditionSatisfied = blnIsConditionSatisfied ||
condition.IsConditionSatisfied();
}
return blnIsConditionSatisfied;
}
#endregion
#region prop
/// <summary>
/// Gets or sets the trigger.
/// </summary>
/// <value>The trigger.</value>
public override Trigger Trigger
{
get
{
return trigger;
}
set
{
trigger = value;
foreach (ConditionBase condition in conditions)
{
condition.Trigger = value;
}
}
}
#endregion
#region dtor
/// <summary>
/// Releases unmanaged resources and performs other cleanup operations before the
/// <see cref="Trigger<K, T>"/> is reclaimed by garbage collection.
/// </summary>
~Or()
{
Dispose(false);
}
#endregion
#region overrides
/// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
/// <param name="blnDisposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected override void Dispose(bool blnDispose)
{
if (!isDisposed && blnDispose)
{
if (null != conditions)
{
foreach (ConditionBase condition in conditions)
{
condition.Dispose();
}
}
isDisposed = true;
GC.SuppressFinalize(this);
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.