コード例 #1
0
 private void FindDirection()
 {
     if (CurrentSources.Count != 0 || VoltageSources.Count != 0)
     {
         IComponentBase component;
         if (CurrentSources.Count != 0)
         {
             component = CurrentSources[0];
         }
         else
         {
             component = VoltageSources[0];
         }
         do
         {
             if (component[1].Component is Node)
             {
                 if (Node_2.Equals(component[1].Component))
                 {
                     DirectionCurrent = Direction.Node_1_to_Node_2;
                 }
                 else
                 {
                     DirectionCurrent = Direction.Node_2_to_Node_1;
                 }
                 return;
             }
             else
             {
                 component = component[1].ConnectedComponent;
             }
         } while (true);
     }
 }
コード例 #2
0
        public async static void GetAllContent(string SectionContent, Node_1 n1_iteration)
        {
            string n1_andderivatives = SectionContent;

            //Get N1 title and content
            string n1_pattern      = @"(^=|\n=)=([^=]?.+?)==((.|\n)*?)(?=($|\n===))";
            Regex  regex_select_n1 = new Regex(n1_pattern);
            Match  m_n1            = regex_select_n1.Match(SectionContent);

            if (m_n1.Success)
            {
                n1_iteration.Title = m_n1.Groups[2].Value;

                string n1_content = m_n1.Groups[3].Value;
                n1_iteration.Content = n1_content;
            }



            string n2_pattern_and_deriv = @"(^=|\n=)==([^=]?.+?)===((\n|.)*?)(?=($|\n={3}(\w|\d|\s)))";

            Regex           regex_select_n2_and_deriv  = new Regex(n2_pattern_and_deriv);
            MatchCollection n2_match_collection        = regex_select_n2_and_deriv.Matches(SectionContent);
            int             n_2_match_collection_count = n2_match_collection.Count;

            if (n_2_match_collection_count > 0)
            {
                List <Node_2> n2_list = new List <Node_2>();

                foreach (Match match_n2 in n2_match_collection)
                {
                    Node_2 node_2_interation = new Node_2();


                    string n2_only         = @"(^=|\n=)==([^=]?.+?)===((.|\n)*?)(?=($|\n={3,5}(\w|\d|\s)))";
                    Regex  regex_select_n2 = new Regex(n2_only);
                    Match  m_n2            = regex_select_n2.Match(match_n2.Value);

                    node_2_interation.Title = m_n2.Groups[2].Value;

                    string n2_content = m_n2.Groups[3].Value;
                    node_2_interation.Content = n2_content;


                    string          n3_pattern_and_deriv      = @"(^=|\n=)===([^=].+?)====((\n|.)*?)(?=($|\n={4}(\w|\d|\s)))";
                    Regex           regex_select_n3_and_deriv = new Regex(n3_pattern_and_deriv);
                    MatchCollection n3_match_collection       = regex_select_n3_and_deriv.Matches(m_n2.Value);

                    int n_3_match_collection_count = n3_match_collection.Count;

                    if (n_3_match_collection_count > 0)
                    {
                        List <Node_3> n3_list = new List <Node_3>();

                        foreach (Match m_n3 in n3_match_collection)
                        {
                            Node_3 node_3_iteration = new Node_3();

                            node_3_iteration.Title = m_n3.Groups[2].Value;

                            string n3_content = m_n2.Groups[3].Value;

                            node_3_iteration.Content = n3_content;

                            string          n4_pattern_and_deriv      = @"(^=|\n=)====([^=].+?)=====((\n|.)*?)(?=($|\n={5}(\w|\d|\s)))";
                            Regex           regex_select_n4_and_deriv = new Regex(n4_pattern_and_deriv);
                            MatchCollection n4_match_collection       = regex_select_n4_and_deriv.Matches(m_n3.Value);

                            int n_4_match_collection_count = n4_match_collection.Count;

                            if (n_4_match_collection_count > 0)
                            {
                                List <Node_4> n4_list = new List <Node_4>();

                                foreach (Match m_n4 in n4_match_collection)
                                {
                                    Node_4 node_4_iteration = new Node_4();

                                    node_4_iteration.Title = m_n4.Groups[2].Value;

                                    string n4_content = m_n4.Groups[3].Value;
                                    node_4_iteration.Content = n4_content;

                                    //Add n4 iteration to list
                                    n4_list.Add(node_4_iteration);
                                }
                                //Add n4 list to n3 iteration
                                node_3_iteration.Node_4_list = n4_list;
                            }

                            //Add n3 iteration to n3 list
                            n3_list.Add(node_3_iteration);
                        }

                        //Add n3 list to n2 iteration
                        node_2_interation.Node_3_list = n3_list;
                    }

                    //Add n2 iteration to n2 list
                    n2_list.Add(node_2_interation);
                }
                //add n2 list to n1 iteration
                n1_iteration.Node_2_list = n2_list;
            }
        }