-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from quasarke/master
Updating personal fork
- Loading branch information
Showing
76 changed files
with
809 additions
and
522 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Arke.DSL.Step.Settings; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Arke.DSL.Step | ||
{ | ||
public class NodeData | ||
{ | ||
public string Text { get; set; } | ||
public string Category { get; set; } | ||
public int Key { get; set; } | ||
public NodeProperties Properties { get; set; } | ||
|
||
[JsonConstructor] | ||
public NodeData(string text, string category, int key, object properties) | ||
{ | ||
var settingsFactory = new SettingsFactory(); | ||
Key = key; | ||
Text = text; | ||
Category = category; | ||
Properties = settingsFactory.CreateProperties(category, (JObject)properties); | ||
} | ||
} | ||
|
||
public abstract class NodeProperties | ||
{ | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public Direction Direction { get; set; } | ||
|
||
public virtual NodeProperties ConvertFromJObject(JObject jObject) | ||
{ | ||
SetDirection(jObject.GetValue("Direction").Value<string>()); | ||
return this; | ||
} | ||
|
||
private void SetDirection(string direction) | ||
{ | ||
switch (direction) | ||
{ | ||
case "Incoming": | ||
Direction = Direction.Incoming; | ||
break; | ||
case "Outgoing": | ||
Direction = Direction.Outgoing; | ||
break; | ||
default: | ||
Direction = Direction.Both; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public class LinkData | ||
{ | ||
public int From { get; set; } | ||
public int To { get; set; } | ||
public string FromPort { get; set; } | ||
public string ToPort { get; set; } | ||
} | ||
|
||
public class CallFlowDsl | ||
{ | ||
public List<NodeData> NodeDataArray { get; set; } | ||
public List<LinkData> LinkDataArray { get; set; } | ||
|
||
public Dictionary<int, Step> GetStepsFromDsl() | ||
{ | ||
var stepList = new Dictionary<int, Step>(); | ||
foreach (var node in NodeDataArray) | ||
{ | ||
var step = new Step() | ||
{ | ||
NodeData = node, | ||
LinkedSteps = LinkDataArray.AsQueryable().Where(s => s.From == node.Key).ToList() | ||
}; | ||
stepList.Add(node.Key, step); | ||
} | ||
return stepList; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Arke.DSL.Step.Settings; | ||
|
||
namespace Arke.DSL.Step | ||
{ | ||
public class Step | ||
{ | ||
public NodeData NodeData { get; set; } | ||
public List<LinkData> LinkedSteps { get; set; } | ||
|
||
public int GetStepFromConnector(string connectorName) | ||
{ | ||
try | ||
{ | ||
return LinkedSteps.Single(s => s.FromPort == connectorName).To; | ||
} | ||
catch (Exception) | ||
{ | ||
throw new StepNotFoundException($"Connector {connectorName} not found on {NodeData.Key}"); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.