/// <summary>
        /// Ants are implemented predominantly as per "Ant Colony Optimisation" Dorigo and Stutzle (2004), Ch3.8, p103.
        /// </summary>
        /// <param name="id">The ant's unique integer Id.</param>
        /// <param name="problemData">Provides access to the problem-specific parameters and data matrices.</param>
        /// <param name="nodeSelector">Used to select the next node to move to.</param>
        public Ant(int id, IProblemData problemData, INodeSelector nodeSelector)
        {
            Id = id;
              _problemData = problemData;
              _nodeSelector = nodeSelector;

              // Ant ultimately returns to starting node.
              _tour = new int[_problemData.NodeCount + 1];
              _visited = new bool[_problemData.NodeCount];
        }
      /// <exception cref="ArgumentNullException">
      /// <paramref name="host"/> or
      /// <paramref name="nodeSelector"/> is <see langword="null" />.</exception>
      public PluralsightNodeParser(string host, INodeSelector nodeSelector)
      {
         if (host == null) 
            throw new ArgumentNullException("host");

         if (nodeSelector == null)
            throw new ArgumentNullException("nodeSelector");

         _host = new Uri(host);

         _nodeSelector = nodeSelector;
      }
예제 #3
0
        public void OpenSelectDialog(string newTabTitle = null)
        {
            if (_nodeSelector != null)
            {
                MyTab.TabParent.SwitchOnTab(_nodeSelector);
                return;
            }

            _nodeSelector = _nodeSelectorFactory.CreateSelector();
            _nodeSelector.OnEntitySelectedResult += JournalViewModel_OnNodeSelectedResult;
            _nodeSelector.TabClosed += NodeSelector_TabClosed;
            MyTab.TabParent.AddSlaveTab(MyTab, _nodeSelector);
        }
예제 #4
0
        /// <exception cref="ArgumentNullException">
        /// <paramref name="nodeSelector"/> or
        /// <paramref name="nodeParser"/> is <see langword="null" />.</exception>
        public PluralsightCatalogParser(INodeSelector nodeSelector, INodeParser nodeParser)
        {
            if (nodeSelector == null)
            {
                throw new ArgumentNullException("nodeSelector");
            }

            if (nodeParser == null)
            {
                throw new ArgumentNullException("nodeParser");
            }

            _nodeSelector = nodeSelector;
            _nodeParser   = nodeParser;
        }
        /// <exception cref="ArgumentNullException">
        /// <paramref name="host"/> or
        /// <paramref name="nodeSelector"/> is <see langword="null" />.</exception>
        public PluralsightNodeParser(string host, INodeSelector nodeSelector)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            if (nodeSelector == null)
            {
                throw new ArgumentNullException("nodeSelector");
            }

            _host = new Uri(host);

            _nodeSelector = nodeSelector;
        }
예제 #6
0
 void NodeSelector_TabClosed(object sender, EventArgs e)
 {
     _nodeSelector = null;
 }
예제 #7
0
 public Runner(INodeSelector nodeSelector,
               IConsoleDecorator consoleDecorator)
 {
     _nodeSelector     = nodeSelector;
     _consoleDecorator = consoleDecorator;
 }
예제 #8
0
        private static void MergeDifferences(INodeSelector source, List<NodeDifference> differences)
        {
            foreach (var diff in differences)
            {
                string selector = Fun.Val(() =>
                {
                    switch (diff.Action)
                    {
                        case NodeDiffAction.Append:
                            var returnS = diff.MatchSelector.SubstringBeforeLast(">").SubstringAfterIfExists("html>");
                            return returnS;
                        case NodeDiffAction.Replace:
                            string ret = diff.MatchSelector;
                            if (diff.Node.hasAttribute(XMatchAttribute))
                            {
                                string attrib = diff.Node.getAttribute(XMatchAttribute);
                                string[] attribs = attrib.Split(',');
                                foreach (string matchingAttrib in attribs)
                                {
                                    string matchingAttribTrimmed = matchingAttrib.Trim();
                                    string val = diff.Node.getAttribute(matchingAttribTrimmed);
                                    ret += "[" + matchingAttribTrimmed;
                                    if (string.IsNullOrEmpty(val))
                                    {

                                    }
                                    else
                                    {
                                        ret += "='" + val + "'";
                                    }
                                    ret += "]";
                                }
                            }
                            return ret;
                        default:
                            throw new Exception();
                    }
                });
                var nodes = source.querySelectorAll(selector);
                if (nodes.Count != 1)
                {
                    throw new Exception("No Matching Single Node Found: " + diff.MatchSelector);
                }
                var node = nodes[0];
                var parentNode = node.parentNode;
                switch (diff.Action)
                {
                    case NodeDiffAction.Append:
                        node.appendChild(diff.Node);
                        break;
                    case NodeDiffAction.Replace:
                        parentNode.replaceChild(diff.Node, node);
                        break;
                    default:
                        throw new NotImplementedException();
                }
                if (diff.Children != null)
                {
                    MergeDifferences(node, diff.Children);
                }
            }
        }