コード例 #1
0
ファイル: CircuitFileParser.cs プロジェクト: rveens/OOPA
        /// <summary>
        /// Builds all nodes due the retrieved nodes data from the Circuit File.
        /// </summary>
        /// <param name="parsedNodes">A list containing all data of the retrieved nodes from the Circuit file.</param>
        /// <param name="cbnv">The visitor used to bind the circuit nodes.</param>
        /// <returns>A dictionary containing all built nodes out of the retrieved nodes data from the Circuit file.</returns>
        private static Dictionary<string, Node> BuildNodes(IEnumerable<string> parsedNodes, CircuitBindNodeVisitor cbnv)
        {
            const string METHOD_TAG = "BuildNodes";

            var nodes = new Dictionary<string, Node>();
            Node node = null;

            try
            {
                
                foreach (var parsedNode in parsedNodes)
                {
                    node = FactoryMethod<string, Node>.create(parsedNode.Split(':')[1]);

                    node.accept(cbnv);
                    nodes.Add(parsedNode.Split(':')[0].ToLower(), node);
                }
            }
            catch (Exception)
            {
                if (node != null)
                {
                    throw new CurrentNodeNotFoundException(CLASS_TAG, METHOD_TAG,
                        "Unexpected value for node '" + node.GetType() + "' received.");
                }
                    
                Console.WriteLine(@"Unexpected value for node found!");
            }

            return nodes;
        }
コード例 #2
0
ファイル: CircuitFileParser.cs プロジェクト: rveens/OOPA
        /// <summary>
        /// Builds all nodes due the retrieved nodes data from the Circuit File.
        /// </summary>
        /// <param name="parsedNodes">A list containing all data of the retrieved nodes from the Circuit file.</param>
        /// <param name="cbnv">The visitor used to bind the circuit nodes.</param>
        /// <returns>A dictionary containing all built nodes out of the retrieved nodes data from the Circuit file.</returns>
        private static Dictionary <string, Node> BuildNodes(IEnumerable <string> parsedNodes, CircuitBindNodeVisitor cbnv)
        {
            const string METHOD_TAG = "BuildNodes";

            var  nodes = new Dictionary <string, Node>();
            Node node  = null;

            try
            {
                foreach (var parsedNode in parsedNodes)
                {
                    node = FactoryMethod <string, Node> .create(parsedNode.Split(':')[1]);

                    node.accept(cbnv);
                    nodes.Add(parsedNode.Split(':')[0].ToLower(), node);
                }
            }
            catch (Exception)
            {
                if (node != null)
                {
                    throw new CurrentNodeNotFoundException(CLASS_TAG, METHOD_TAG,
                                                           "Unexpected value for node '" + node.GetType() + "' received.");
                }

                Console.WriteLine(@"Unexpected value for node found!");
            }

            return(nodes);
        }