-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3169815
commit fcd1a79
Showing
5 changed files
with
130 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using IFTTT.Constants; | ||
using IFTTT.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace IFTTT.Interfaces | ||
{ | ||
public interface IIFTTTExpressionProcessor | ||
{ | ||
event EventHandler<IFTTTExpressionGroup> ExpressionGroupPassed; | ||
bool ProcessExpression(IFTTTExpression expression); | ||
bool ProcessExpressionGroup(IFTTTExpressionGroup expressionGroup); | ||
bool ProcessExpressions(IEnumerable<IFTTTExpression> expressions, bool isShorted, Circuit circuit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace IFTTT.Models | ||
{ | ||
public class IFTTTTrigger | ||
{ | ||
public string ListForGroupName { get; set; } | ||
public string TriggerGroupName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using IFTTT.Interfaces; | ||
using IFTTT.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace IFTTT.Processors | ||
{ | ||
public class IFTTTExpressionTriggerProcessor | ||
{ | ||
private readonly IIFTTTExpressionProcessor expressionProcessor; | ||
|
||
public IFTTTExpressionTriggerProcessor(IIFTTTExpressionProcessor expressionProcessor) | ||
{ | ||
this.expressionProcessor = expressionProcessor; | ||
this.expressionProcessor.ExpressionGroupPassed += ExpressionProcessor_ExpressionGroupPassed; | ||
} | ||
|
||
public IEnumerable<IFTTTTrigger> Triggers { get; set; } | ||
public IEnumerable<IFTTTExpressionGroup> ExpressionGroups { get; set; } | ||
|
||
private void ExpressionProcessor_ExpressionGroupPassed(object sender, IFTTTExpressionGroup e) | ||
{ | ||
var trigger = Triggers.FirstOrDefault(x => x.ListForGroupName == e.Name); | ||
if (trigger != null) | ||
{ | ||
var group = ExpressionGroups.FirstOrDefault(x => x.Name == trigger.TriggerGroupName); | ||
if (group != null) expressionProcessor.ProcessExpressionGroup(group); | ||
} | ||
} | ||
} | ||
} |