public async void sdf()
        {
            // Prepare
            var expectedDestination = new DestinationNode
            {
                AcceptedProducts = new List <ProductType>(new []
                {
                    ProductTypes.Paket
                }),
                Location = Locations.PZ_50
            };
            var testee = new DestinationLocator(new []
            {
                expectedDestination
            });

            var order = OrderBuilder
                        .At(Locations.KölnerDom)
                        .From(2020, 12, 07)
                        .Every(DayOfWeek.Monday)
                        .Between(new TimeSpan(16, 00, 00), new TimeSpan(20, 00, 00))
                        .Load(1, ContainerTypes.Kiste, ProductTypes.Paket)
                        .Build();

            // Execute
            var result = await testee.GetDestination(order.Positions.First());

            // Verify
            Assert.Equal <DestinationNode>(expectedDestination, result);
        }
        public void OptimizeTest_InputHasDependenciesOfTwoGroup_GivesProperOutput()
        {
            DestinationNode        locA         = new DestinationNode("Location A");
            DestinationNode        locC         = new DestinationNode("Location C", locA);
            DestinationNode        locB         = new DestinationNode("Location B", locC);
            DestinationNode        locE         = new DestinationNode("Location D");
            DestinationNode        locF         = new DestinationNode("Location E", locE);
            DestinationNode        locD         = new DestinationNode("Location F", locF);
            List <DestinationNode> allLocations = new List <DestinationNode> {
                locB,
                locF,
                locD,
                locC,
                locA,
                locE
            };
            List <DestinationNode> expectedLocations = new List <DestinationNode>
            {
                locA,
                locC,
                locB,
                locE,
                locF,
                locD
            };
            Optimizer optimizer = new Optimizer(allLocations);

            CollectionAssert.AreEqual(expectedLocations, optimizer.Optimize());
        }
Example #3
0
 /// <summary>
 /// Compiles the supplied expression tree to the CSharp code string.
 /// </summary>
 /// <param name="resultNode">The root node of the expression tree.</param>
 /// <returns>The python script representation of the expression tree.</returns>
 public string Compile(DestinationNode resultNode)
 {
     _resultCode = new StringBuilder();
     //_resultNodeVisited = false;
     Visit(resultNode);
     return _resultCode.ToString();
 }
Example #4
0
        /// <summary>
        /// Compiles the supplied expression tree to the Python prepared script string.
        /// </summary>
        /// <param name="resultNode">The root node of the expression tree.</param>
        /// <returns>The python prepared script representation of the expression tree.</returns>
        public string PrepareScript(DestinationNode resultNode)
        {
            _isInPrepareMode = true;
            string script = Compile(resultNode);
            _isInPrepareMode = false;

            return script;
        }
 public override IDictionary<string, string> PrepareMultipleScripts(DestinationNode node)
 {
     try
     {
         return NodeCompiler.PrepareMultipleScripts(node);
     }
     catch (Exception ex)
     {
         throw new ExpressionTreeCompilerException("Can't compile the tree. See inner exception for details.", ex);
     }
 }
 /// <summary>
 /// Precompile the expression tree into a prepared script.
 /// </summary>
 /// <param name="node">Root node of the expression tree that should be compiled and executed.</param>
 /// <param name="parametresToReplace">String value to replace the placeholder in the script</param>
 /// <returns>Prepared script.</returns>
 public override string PrepareScript(DestinationNode node, IDictionary<string, string> parametresToReplace)
 {
     try
     {
         return NodeCompiler.PrepareScript(node, parametresToReplace);
     }
     catch (Exception ex)
     {
         throw new ExpressionTreeCompilerException("Can't compile the tree. See inner exception for details.", ex);
     }
 }
Example #7
0
        public void DestinationsNodeTest()
        {
            FormatterNode formatter = new TextFormatterNode();
            SinkNode      sink      = new CustomSinkNode();

            DestinationNode node = new DestinationNode();

            GeneratedApplicationNode.Nodes.Add(node);
            node.Formatter = formatter;
            node.Sink      = sink;

            Assert.AreEqual(formatter, node.Formatter);
            Assert.AreEqual(sink, node.Sink);
        }
        public void OptimizeTest_DestinationIsThePreviousOfMultipleDestinations_ThrowsException()
        {
            DestinationNode        locA         = new DestinationNode("Location A");
            DestinationNode        locB         = new DestinationNode("Location B", locA);
            DestinationNode        locC         = new DestinationNode("Location C", locA);
            List <DestinationNode> allLocations = new List <DestinationNode> {
                locA,
                locB,
                locC
            };
            Optimizer optimizer = new Optimizer(allLocations);

            optimizer.Optimize();
        }
Example #9
0
        /// <summary>
        /// Compiles the supplied expression tree to the CSharp prepared code string.
        /// </summary>
        /// <param name="resultNode">The root node of the expression tree.</param>
        /// <param name="parametresToReplace">String value to replace the placeholder in the script</param>
        /// <returns>The python prepared script representation of the expression tree.</returns>
        public string PrepareScript(DestinationNode resultNode, IDictionary<string, string> parametresToReplace)
        {
            _isInPrepareMode = true;
            var script = Compile(resultNode);
            _isInPrepareMode = false;

            if (parametresToReplace != null && parametresToReplace.Count > 0)
            {
                foreach (var str in parametresToReplace)
                {
                    script = script.Replace(str.Key, str.Value);
                }
            }

            return script;
        }
        public void OptimizeTest_InputHasCircularDependency_ThrowsException()
        {
            DestinationNode locA = new DestinationNode("Location A");
            DestinationNode locB = new DestinationNode("Location B");
            DestinationNode locC = new DestinationNode("Location C");

            locA.Previous = locB;
            locB.Previous = locC;
            locC.Previous = locA;
            List <DestinationNode> allLocations = new List <DestinationNode> {
                locA,
                locB,
                locC
            };
            Optimizer optimizer = new Optimizer(allLocations);

            optimizer.Optimize();
        }
Example #11
0
        /// <summary>
        /// Creates the destination node from connector.
        /// </summary>
        /// <param name="objectsCollection">The objects collection.</param>
        /// <param name="connector">The connector.</param>
        /// <returns>DestinationNode.</returns>
        public DestinationNode CreateDestinationNodeFromConnector(ICollection<IExpressionObjectBase> objectsCollection, IConnectorIn connector)
        {            
                RestoreConnections(objectsCollection);
                Validate(objectsCollection);

                _values = new Dictionary<string, object>();

                if (connector.Connection != null && connector.Connection.Source != null)
                {
                    var destinationNode = new DestinationNode();
                    destinationNode.ResultNodes.Add(
                        CreateResultNode(connector, connector.DataType, Constants.Result));

                    return destinationNode;
                }

            return null;
        }
Example #12
0
 public void Evaluate(float timeInSecond)
 {
     SourceNode?.Evaluate(timeInSecond);
     DestinationNode?.Evaluate(timeInSecond);
     if (SourceNode == null)
     {
         Runtime.CGfxAnimationRuntime.CopyPose(OutPose, DestinationNode.OutPose);
     }
     if (DestinationNode == null)
     {
         Runtime.CGfxAnimationRuntime.CopyPose(OutPose, SourceNode.OutPose);
     }
     if (EvaluateWeight != null)
     {
         Weight = EvaluateWeight.Invoke();
     }
     Runtime.CGfxAnimationRuntime.BlendPose(OutPose, SourceNode.OutPose, DestinationNode.OutPose, Weight);
 }
        public void OptimizeTest_InputHasTwoDependencies_GivesProperOutput()
        {
            DestinationNode        locA         = new DestinationNode("Location A");
            DestinationNode        locC         = new DestinationNode("Location C", locA);
            DestinationNode        locB         = new DestinationNode("Location B", locC);
            List <DestinationNode> allLocations = new List <DestinationNode> {
                locB,
                locC,
                locA
            };
            List <DestinationNode> expectedLocations = new List <DestinationNode>
            {
                locA,
                locC,
                locB
            };
            Optimizer optimizer = new Optimizer(allLocations);

            CollectionAssert.AreEqual(expectedLocations, optimizer.Optimize());
        }
Example #14
0
        private void ImagesTreeList_DragDrop(object sender, DragEventArgs e)
        {
            DevExpress.XtraTreeList.Nodes.TreeListNode DestinationNode;

            Point pt = ((DevExpress.XtraTreeList.TreeList)sender).PointToClient(new Point(e.X, e.Y));
            //DevExpress.XtraTreeList.Nodes.TreeListNode DestinationNode = ((DevExpress.XtraTreeList.Nodes.TreeListNode)sender).Calc
            var _Info = ImagesTreeList.CalcHitInfo(pt);

gto:
            DestinationNode = _Info.Node;
            if (DestinationNode == null)
            {
                goto gto;
            }

            DevExpress.XtraTreeList.Nodes.TreeListNode _Node = (DevExpress.XtraTreeList.Nodes.TreeListNode)e.Data.GetData("DevExpress.XtraTreeList.Nodes.TreeListNode");

StartGetNodeID:

            var _DestinationID = DestinationNode.GetValue("ID").ToString();
            var _NodeID = _Node.GetValue("ID").ToString();

            if (DestinationNode.GetValue("IsFolder").ToString().ToLower() == "1")
            {
                var _Group = _GroupCollection.GetGroupByID(_DestinationID);

                if (_Node.GetValue("IsFolder").ToString().ToLower() == "1")
                {
                    _GroupCollection.MoveGroupToGroup(_Node.GetValue("ID").ToString(), _DestinationID);
                }
            }
            else
            {
                DestinationNode = DestinationNode.ParentNode;
                goto StartGetNodeID;
            }
            e.Effect = DragDropEffects.None;
            PopulateTreeView();
        }
Example #15
0
 public void InitializePose(Pose.CGfxSkeletonPose pose)
 {
     OutPose = pose.Clone();
     SourceNode?.InitializePose(pose);
     DestinationNode?.InitializePose(pose);
 }
Example #16
0
 public override string ToString()
 {
     return(SourceNode.ToString() + " -> " + DestinationNode.ToString());
 }
Example #17
0
        /// <summary>
        /// Visits the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        public void Visit(DestinationNode node)
        {
            //Custom mode we dont need the function cause it will be attached on compilation.
            if (!_isInPrepareCustomMode)
            {
                //AppendToResult("var result = null;");
            }

            foreach (var resultNode in node.ResultNodes)
            {
                resultNode.AcceptVisitor(this);
            }

            if (!_isInPrepareCustomMode)
            {
                //AppendToResult(Environment.NewLine);
                //AppendToResult("return result;");
            }
        }
Example #18
0
 public void Notifying(GamePlay.Component.GComponent component)
 {
     SourceNode?.Notifying(component);
     DestinationNode?.Notifying(component);
 }
Example #19
0
        /// <summary>
        /// Adds the destination node.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="destinationNode">The destination node.</param>
        /// <param name="prefix">The prefix.</param>
        private void AddDestinationNode(DestinationField field, DestinationNode destinationNode, string prefix = "")
        {
            if (field.ConnectorIn.Connection != null && field.ConnectorIn.Connection.Source != null)
            {
                var name = prefix + field.SystemName;

                destinationNode.ResultNodes.Add(
                    CreateResultNode(field.ConnectorIn, field.DataType, name));
            }

            foreach (var subfield in field.Subfields.OfType<DestinationField>())
            {
                AddDestinationNode(subfield, destinationNode, prefix + field.SystemName + ".");
            }
        }
Example #20
0
        /// <summary>
        /// Prepares the multiple scripts.
        /// </summary>
        /// <param name="resultNode">The result node.</param>
        /// <returns>Dictionary{System.StringSystem.String}.</returns>
        public Dictionary<string, string> PrepareMultipleScripts(DestinationNode resultNode)
        {
            _isInPrepareMode = true;

            var result = new Dictionary<string, string>();
            _resultCode = new StringBuilder();

            foreach (var node in resultNode.ResultNodes)
            {
                _resultCode.Clear();
                node.AcceptVisitor(this);
                result[node.FieldName] = _resultCode.ToString();
            }

            _isInPrepareMode = false;

            return result;
        }
Example #21
0
 public DestinationNode(string name, DestinationNode previous)
 {
     Name     = name;
     Previous = previous;
 }
Example #22
0
        /// <summary>
        /// To the expression node.
        /// </summary>
        /// <param name="destination">The destination.</param>
        /// <returns>DestinationNode.</returns>
        private DestinationNode ToExpressionNode(DestinationFieldList destination)
        {
            var destinationNode = new DestinationNode();

            foreach (var field in destination.Fields)
            {
                AddDestinationNode(field, destinationNode);
            }

            return destinationNode;
        }