public void TestConnectorSerialization() { var obj = new ThreeInOneOutExpression(); var tw = new StringWriter(); using (var xw = XmlWriter.Create(tw)) { xw.WriteStartElement("Node"); obj.Serialize(xw); xw.WriteEndElement(); } var sr = new StringReader(tw.ToString()); using (var wr = XmlReader.Create(sr)) { wr.ReadToFollowing("Node"); var result = new ThreeInOneOutExpression(); result.Deserialize(wr); Assert.AreEqual(obj.Id, result.Id); Assert.AreEqual(obj.Connector1In.Id, result.Connector1In.Id); Assert.AreEqual(obj.Connector2In.Id, result.Connector2In.Id); Assert.AreEqual(obj.Connector3In.Id, result.Connector3In.Id); Assert.AreEqual(obj.ConnectorOut.Id, result.ConnectorOut.Id); } }
public void CloneTest() { var source = new ThreeInOneOutExpression { ExpressionName = "source", FunctionName = "func", Width = 1, Height = 2, Top = 3, Left = 4, Connector1In = {Name = "1"}, Connector2In = {Name = "2"}, Connector3In = {Name = "3"}, ConnectorOut = {Name = "4"} }; var cloneTo = (ThreeInOneOutExpression)source.Clone(); Assert.AreEqual(source.ExpressionName, cloneTo.ExpressionName); Assert.AreEqual(source.FunctionName, cloneTo.FunctionName); Assert.AreEqual(source.Width, cloneTo.Width); Assert.AreEqual(source.Height, cloneTo.Height); Assert.AreEqual(source.Top, cloneTo.Top); Assert.AreEqual(source.Left, cloneTo.Left); Assert.AreNotEqual(source.Id, cloneTo.Id); Assert.AreNotEqual(source.Connector1In.Id, cloneTo.Connector1In.Id); Assert.AreNotEqual(source.Connector2In.Id, cloneTo.Connector2In.Id); Assert.AreNotEqual(source.Connector3In.Id, cloneTo.Connector3In.Id); Assert.AreNotEqual(source.ConnectorOut.Id, cloneTo.ConnectorOut.Id); Assert.AreEqual(source.Connector1In.Name, cloneTo.Connector1In.Name); Assert.AreEqual(source.Connector2In.Name, cloneTo.Connector2In.Name); Assert.AreEqual(source.Connector3In.Name, cloneTo.Connector3In.Name); Assert.AreEqual(source.ConnectorOut.Name, cloneTo.ConnectorOut.Name); }
public void TestConnectorProperties() { var obj = new ThreeInOneOutExpression(); TestsHelper.TestPublicPropertiesGetSet(new ThreeInOneOutExpression()); Assert.IsNotNull(obj.Connector1In); Assert.IsNotNull(obj.Connector2In); Assert.IsNotNull(obj.Connector3In); Assert.IsNotNull(obj.ConnectorOut); }
/// <summary> /// Clones this instance. /// </summary> /// <returns>ExpressionObjectBase.</returns> public override ExpressionObjectBase Clone() { var clone = new ThreeInOneOutExpression(Type) { ExpressionName = ExpressionName, FunctionName = FunctionName, Width = Width, Height = Height, Top = Top, Left = Left }; Connector1In.Clone(clone.Connector1In); Connector2In.Clone(clone.Connector2In); Connector3In.Clone(clone.Connector3In); ConnectorOut.Clone(clone.ConnectorOut); return clone; }
public void GetConnectorsTest() { var source = new ThreeInOneOutExpression { Connector1In = {Name = "1"}, Connector2In = {Name = "2"}, Connector3In = {Name = "3"}, ConnectorOut = {Name = "4"} }; var conn = source.GetConnectors(); var connectors = conn as IList<IConnector> ?? conn.ToList(); Assert.IsTrue(connectors.Any(x => x.Name == "1")); Assert.IsTrue(connectors.Any(x => x.Name == "2")); Assert.IsTrue(connectors.Any(x => x.Name == "3")); Assert.IsTrue(connectors.Any(x => x.Name == "4")); }
public void DoesInherit_IExpressionProcessor() { var stub = new ThreeInOneOutExpression(); Assert.IsNotNull(stub as IExpressionProcessor); }
public void IsValidTest() { var source = new ThreeInOneOutExpression(); Assert.IsFalse(source.IsValid); source.Connector1In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.IsValid); source.Connector2In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.IsValid); source.Connector3In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.IsValid); source.ConnectorOut.ConnectedTo = new ConnectorIn(null); Assert.IsTrue(source.IsValid); }
public void ValidationMessageTest() { var source = new ThreeInOneOutExpression { Connector1In = {Name = "c1"}, Connector2In = {Name = "c2"}, Connector3In = {Name = "c3"}, ConnectorOut = {Name = "co"} }; Assert.IsTrue(source.ValidationMessage.Contains("c1")); Assert.IsTrue(source.ValidationMessage.Contains("c2")); Assert.IsTrue(source.ValidationMessage.Contains("c3")); Assert.IsTrue(source.ValidationMessage.Contains("Result")); source.Connector1In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.ValidationMessage.Contains("c1")); Assert.IsTrue(source.ValidationMessage.Contains("c2")); Assert.IsTrue(source.ValidationMessage.Contains("c3")); Assert.IsTrue(source.ValidationMessage.Contains("Result")); source.Connector2In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.ValidationMessage.Contains("c1")); Assert.IsFalse(source.ValidationMessage.Contains("c2")); Assert.IsTrue(source.ValidationMessage.Contains("c3")); Assert.IsTrue(source.ValidationMessage.Contains("Result")); source.Connector3In.ConnectedTo = new ConnectorOut(null); Assert.IsFalse(source.ValidationMessage.Contains("c1")); Assert.IsFalse(source.ValidationMessage.Contains("c2")); Assert.IsFalse(source.ValidationMessage.Contains("c3")); Assert.IsTrue(source.ValidationMessage.Contains("Result")); source.ConnectorOut.ConnectedTo = new ConnectorIn(null); Assert.IsTrue(string.IsNullOrEmpty(source.ValidationMessage)); }
/// <summary> /// Initializes a new instance of the <see cref="ConditionDialogViewModel"/> class. /// </summary> public ConditionDialogViewModel() { _condition = new ThreeInOneOutExpression(); }
/// <summary> /// Initializes a new instance of the <see cref="ConditionDialogViewModel"/> class. /// </summary> /// <param name="condition">The condition.</param> public ConditionDialogViewModel(ThreeInOneOutExpression condition) { _condition = condition; }
/// <summary> /// Determines whether [is valid mapping] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(ThreeInOneOutExpression expression, SourceField sourceContext) { if (expression.Type == ExpressionNodeType.FindFirst) { SourceField newSourceContext = null; if (expression.Connector1In != null && expression.Connector1In.Connection != null) newSourceContext = GetSourceContext(expression.Connector1In.Connection.Source); return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, newSourceContext) && expression.Connector3In != null && IsValidMapping(expression.Connector3In, newSourceContext); } return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, sourceContext) && expression.Connector3In != null && IsValidMapping(expression.Connector3In, sourceContext); }
private static void SetupExpressionsDiagram(DiagramViewModel vm) { vm.Palette.Add(new NodeGroup("String Functions", new INodeViewModel[] { new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToUpper) { ExpressionName = "Uppercase", ConnectorIn = { DataType = NodeDataType.String, Name = "String" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToLower) { ExpressionName = "Lowercase", ConnectorIn = { DataType = NodeDataType.String, Name = "String" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.Trim) { ExpressionName = "Trim", ConnectorIn = { DataType = NodeDataType.String, Name = "String" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Concat) { ExpressionName = "Concat", Connector1In = { DataType = NodeDataType.String, Name = "String 1" }, Connector2In = { DataType = NodeDataType.String, Name = "String 2" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Left) { ExpressionName = "Left", Connector1In = { DataType = NodeDataType.String, Name = "String 1" }, Connector2In = { DataType = NodeDataType.String, Name = "String 2" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Right) { ExpressionName = "Right", Connector1In = { DataType = NodeDataType.String, Name = "String 1" }, Connector2In = { DataType = NodeDataType.String, Name = "String 2" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ) })); vm.Palette.Add(new NodeGroup("Date Functions", new INodeViewModel[] { new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AddDays) { ExpressionName = "Add Days", Connector1In = { DataType = NodeDataType.DateTime, Name = "Date" }, Connector2In = { DataType = NodeDataType.Int, Name = "Days Count" }, ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffDays) { ExpressionName = "DateDiff Days", Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" }, Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" }, ConnectorOut = { DataType = NodeDataType.Int, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffHours) { ExpressionName = "DateDiff Hours", Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" }, Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" }, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" } }), vm ), new NodeViewModel<FunctionExpressionNode, ExpressionConnection>( new FunctionExpressionNode(vm, new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", FunctionName = "DateTime.Now", ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateYear) { ExpressionName = "Date Year", ConnectorIn = { DataType = NodeDataType.DateTime, Name = "Date" }, ConnectorOut = { DataType = NodeDataType.Int, Name = "Year" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateQuarter) { ExpressionName = "Date Quarter", ConnectorIn = { DataType = NodeDataType.DateTime, Name = "Date" }, ConnectorOut = { DataType = NodeDataType.Int, Name = "Quarter" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonth) { ExpressionName = "Date Month", ConnectorIn = { DataType = NodeDataType.DateTime, Name = "Date" }, ConnectorOut = { DataType = NodeDataType.Int, Name = "Month" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonthName) { ExpressionName = "Date Month Name", ConnectorIn = { DataType = NodeDataType.DateTime, Name = "Date" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Month Name" } }), vm ), new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>( new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateWeek) { ExpressionName = "Date Week", ConnectorIn = { DataType = NodeDataType.DateTime, Name = "Date" }, ConnectorOut = { DataType = NodeDataType.Int, Name = "Week" } }), vm ), })); vm.Palette.Add(new NodeGroup("Logical Functions", new INodeViewModel[] { new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsLess) { ExpressionName = "Less", Connector1In = { DataType = NodeDataType.Double, Name = "a" }, Connector2In = { DataType = NodeDataType.Double, Name = "b" }, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsGreater) { ExpressionName = "Greater", Connector1In = { DataType = NodeDataType.Double, Name = "a" }, Connector2In = { DataType = NodeDataType.Double, Name = "b" }, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AreEqual) { ExpressionName = "Equals", Connector1In = { DataType = NodeDataType.String, Name = "a" }, Connector2In = { DataType = NodeDataType.String, Name = "b" }, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" } }), vm ), new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>( new ThreeInOneOutExpressionNode(vm, new ThreeInOneOutExpression(ExpressionNodeType.If) { ExpressionName = "Condition", Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" }, Connector2In = { DataType = NodeDataType.String, Name = "When True" }, Connector3In = { DataType = NodeDataType.String, Name = "When False" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ), })); vm.Palette.Add(new NodeGroup("Aggregate Functions", new INodeViewModel[] { new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Add) { ExpressionName = "Add", Connector1In = { DataType = NodeDataType.Double, Name = "Value1"}, Connector2In = { DataType = NodeDataType.Double, Name = "Value2"}, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result"} }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Subtract) { ExpressionName = "Subtract", Connector1In = { DataType = NodeDataType.Double, Name = "Value1" }, Connector2In = { DataType = NodeDataType.Double, Name = "Value2" }, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Multiply) { ExpressionName = "Multiply", Connector1In = { DataType = NodeDataType.Double, Name = "Value1" }, Connector2In = { DataType = NodeDataType.Double, Name = "Value2" }, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Divide) { ExpressionName = "Divide", Connector1In = { DataType = NodeDataType.Double, Name = "Value1" }, Connector2In = { DataType = NodeDataType.Double, Name = "Value2" }, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" } }), vm ), new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>( new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Custom Multiply", FunctionName = "?1 * ?2", Connector1In = { DataType = NodeDataType.Double, Name = "Value1" }, Connector2In = { DataType = NodeDataType.Double, Name = "Value2" }, ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" } }), vm ), })); vm.Palette.Add(new NodeGroup("SPC Functions", new INodeViewModel[] { new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AboveCenterLine) { ExpressionName = "Above Center Line", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.BelowCenterLine) { ExpressionName = "Below Center Line", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingDown) { ExpressionName = "Going Down", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingUp) { ExpressionName = "Going Up", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AlternatingUpAndDown) { ExpressionName = "Alternating Up and Down", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>( new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.LessThanLowerLimits) { ExpressionName = "Less Than LCL/LSL", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Double, Name = "LCL/LSL"}, Connector4In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"}, Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>( new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.GreaterThanUpperLimits) { ExpressionName = "Greater Than UCL/USL", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Double, Name = "UCL/USL"}, Connector4In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"}, Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.Same) { ExpressionName = "Same", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>( new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.Between) { ExpressionName = "Between", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.Double, Name = "Low Value"}, Connector5In = { DataType = NodeDataType.Double, Name = "High Value"}, Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>( new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneAorBeyond) { ExpressionName = "Zone A or beyond", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"}, Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>( new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneBorBeyond) { ExpressionName = "Zone B or beyond", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"}, Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>( new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneCorBeyond) { ExpressionName = "Zone C or beyond", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"}, Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedNumber) { ExpressionName = "Failed Number (attribute)", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"}, Connector3In = { DataType = NodeDataType.Int, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>( new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedPercent) { ExpressionName = "Failed Percent (attribute)", Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"}, Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"}, Connector3In = { DataType = NodeDataType.Double, Name = "X Number"}, Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"}, ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"} }), vm ), })); vm.Palette.Add(new NodeGroup("Constants", new INodeViewModel[] { new NodeViewModel<ConstantExpressionNode, ExpressionConnection>( new ConstantExpressionNode(vm, new ConstantExpression() { ExpressionName = "Constant", ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }), vm ) })); var uis = new SourceFieldList {ExpressionName = "Current User Information", Left = 10, Top = 400}; uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "User Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserName", ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" } }); uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Full Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserFullName", ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" } }); uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.Int, Name = "Person ID", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserPersonId", ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" } }); uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Email Address", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserEmailAddress", ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" } }); uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Last Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserLastName", ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" } }); uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Business Unit", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserBusinessUnitId", ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" } }); // source //var fieldList = new Dictionary<string, object>(); //fieldList["Name"] = "Name"; //fieldList["Title"] = "Title"; //fieldList["PublishDate"] = DateTime.Now; //fieldList["Author"] = "Author"; var sourceNodeList = new SourceFieldList(); //Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = f => GetCRFields(f, sourceNodeList); sourceNodeList.ExpressionName = "Album"; sourceNodeList.Top = 10; sourceNodeList.Left = 10; sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Name", SetName = SourceFieldSetNames.Item, SystemName = "Name", ConnectorOut = { DataType = NodeDataType.String, Name = "Name" } }); sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Title", SetName = SourceFieldSetNames.Item, SystemName = "Title", ConnectorOut = { DataType = NodeDataType.String, Name = "Title" } }); sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "PublishDate", SetName = SourceFieldSetNames.Item, SystemName = "PublishDate", ConnectorOut = { DataType = NodeDataType.String, Name = "PublishDate" } }); sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Author", SetName = SourceFieldSetNames.Item, SystemName = "Author", ConnectorOut = { DataType = NodeDataType.String, Name = "Author" }, SubfieldsRetriever = new CRSubfieldsRetriever() }); //var sourceNodes = SourceNodeFactory.ConvertToSource("Album", fieldList, SourceFieldSetNames.Item); //sourceNodes.Top = 10; //sourceNodes.Left = 10; //sourceNodes.Width = 200; // destination var destinationNodes = DestinationNodeFactory.ConvertToSource(typeof(ExpressionResult)); destinationNodes.Top = 200; destinationNodes.Left = 600 ; var expressions = new List<IExpressionObjectBase>(); expressions.Add(sourceNodeList); //expressions.Add(uis); expressions.Add(destinationNodes); // connection var connection = new Connection { Id = Guid.NewGuid(), Source = new ConnectorOut(null) { Id = sourceNodeList.ConnectorsOut[0].Id }, Sink = new ConnectorIn(null) { Id = destinationNodes.ConnectorsIn[0].Id } }; //expressions.Add(connection); // constant var constantExpr = new ConstantExpression { ExpressionName = "Constant", Top = 10, Left = 250, Value = 10, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }; //expressions.Add(constantExpr); // oneinoneout var oneinoneoutExpr = new OneInOneOutExpression(ExpressionNodeType.ToUpper) { ExpressionName = "Uppercase", Top = 60, Left = 250, ConnectorIn = {DataType = NodeDataType.String, Name = "String"}, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }; //expressions.Add(oneinoneoutExpr); // twoinoneout var twoinoneoutExpr = new TwoInOneOutExpression(ExpressionNodeType.Concat) { ExpressionName = "Concat", Top = 110, Left = 250, Connector1In = { DataType = NodeDataType.String, Name = "String" }, Connector2In = { DataType = NodeDataType.String, Name = "String" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }; //expressions.Add(twoinoneoutExpr); // threeinoneout var threeinoneoutExpr = new ThreeInOneOutExpression(ExpressionNodeType.If) { ExpressionName = "Condition", Top = 180, Left = 250, Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" }, Connector2In = { DataType = NodeDataType.String, Name = "If True" }, Connector3In = { DataType = NodeDataType.String, Name = "If False" }, ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } }; expressions.Add(threeinoneoutExpr); // function var functionExpr = new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", Top = 280, Left = 250, Width = 100, Height = 45, FunctionName = "DateTime.Now", ConnectorOut = {DataType = NodeDataType.DateTime, Name="Result"}}; //expressions.Add(functionExpr); ExpressionTranslator.TranslateToDiagram(expressions, vm); }
private void ToExpressionNodeThreeInOneOutFunctionTest(ExpressionNodeType nodeType, Type functionNode) { var obj = new ExpressionNodeFactory(); var connection1 = new Connection(); connection1.Source = new ConnectorOut(connection1); connection1.Sink = new ConnectorIn(connection1); var connection2 = new Connection(); connection2.Source = new ConnectorOut(connection2); connection2.Sink = new ConnectorIn(connection2); var connection3 = new Connection(); connection3.Source = new ConnectorOut(connection3); connection3.Sink = new ConnectorIn(connection3); var connection4 = new Connection(); connection4.Source = new ConnectorOut(connection4); connection4.Sink = new ConnectorIn(connection4); var destination = new DestinationFieldList { UniqueName = "Destination" }; destination.Fields.Add(new DestinationField(destination)); var source = new SourceFieldList(); source.Fields.Add(new SourceField(source) { Name = "Field" }); source.Fields.Add(new SourceField(source) { Name = "Field" }); source.Fields.Add(new SourceField(source) { Name = "Field" }); var func = new ThreeInOneOutExpression(nodeType) { UniqueName = "Function" }; func.Connector1In.Id = connection1.Sink.Id; source.Fields[0].ConnectorOut.Id = connection1.Source.Id; func.Connector2In.Id = connection2.Sink.Id; source.Fields[1].ConnectorOut.Id = connection2.Source.Id; func.Connector3In.Id = connection3.Sink.Id; source.Fields[2].ConnectorOut.Id = connection3.Source.Id; destination.Fields[0].ConnectorIn.Id = connection4.Sink.Id; func.ConnectorOut.Id = connection4.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, func, connection1, connection2, connection3, connection4 }; var destNode = obj.CreateExpressionNodes(objects); Assert.AreEqual(functionNode, destNode.ResultNodes.FirstOrDefault().Expression.GetType()); }
/// <summary> /// Adds the field node. /// </summary> /// <param name="item">The item.</param> /// <param name="diagramViewModel">The diagram view model.</param> private static void AddFieldNode(ThreeInOneOutExpression item, IDiagramViewModel diagramViewModel) { var node = new ThreeInOneOutExpressionNode(diagramViewModel, item); diagramViewModel.Items.Add(new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>(node, diagramViewModel)); }
public ThreeInOneOutExpressionNode(IDiagramViewModel diagramViewModel, ThreeInOneOutExpression expressionObject) : base(expressionObject) { if (expressionObject == null) throw new ArgumentNullException("expressionObject"); _diagramViewModel = diagramViewModel; IsValidFunc = n => true; UpdateAction = n => { }; Connector1In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector1In), _diagramViewModel); Connector2In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector2In), _diagramViewModel); Connector3In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector3In), _diagramViewModel); ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel); }