Example #1
0
        public static Returnable readPortsFromConfig(string configurationFileName)
        {
            List <int>    portList     = new List <int>();
            List <string> moduleList   = new List <string>();
            List <string> contenerList = new List <string>();

            string        defaultDirectoryPath = Directory.GetCurrentDirectory();
            DirectoryInfo di = new DirectoryInfo((((new DirectoryInfo(defaultDirectoryPath).Parent).Parent).Parent).FullName + "\\Configs\\Management"); //sobczakj

            configurationFilePath = setupDirectoryPath(di.ToString(), configurationFileName);
            using (
                configReader = XmlReader.Create(configurationFilePath))
                try
                {
                    while (configReader.Read())
                    {
                        if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "port"))
                        {
                            if (configReader.HasAttributes)
                            {
                                portList.Add(int.Parse(configReader.GetAttribute("value")));
                            }
                        }
                        else if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "module"))
                        {
                            if (configReader.HasAttributes)
                            {
                                moduleList.Add(configReader.GetAttribute("value"));
                            }
                        }
                        else if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "contener"))
                        {
                            if (configReader.HasAttributes)
                            {
                                contenerList.Add(configReader.GetAttribute("name"));
                            }
                        }
                    }
                    Returnable returnable = new Returnable(portList, moduleList, contenerList);
                    return(returnable);
                }
                catch
                (Exception e)
                {
                    return(null);
                }
        }
        public static Returnable readPortsFromConfig(string configurationFileName)
        {
            List<int> portList = new List<int>();
            List<string> moduleList = new List<string>();
            List<string> contenerList = new List<string>();

            string defaultDirectoryPath = Directory.GetCurrentDirectory();
            DirectoryInfo di = new DirectoryInfo((((new DirectoryInfo(defaultDirectoryPath).Parent).Parent).Parent).FullName+"\\Configs\\Management"); //sobczakj
            configurationFilePath = setupDirectoryPath(di.ToString(), configurationFileName);
            using (
            configReader = XmlReader.Create(configurationFilePath))
                try
                {
                    while (configReader.Read())
                    {
                        if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "port"))
                        {
                            if (configReader.HasAttributes)
                            {
                                portList.Add(int.Parse(configReader.GetAttribute("value")));
                            }
                        }
                        else if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "module"))
                        {
                            if (configReader.HasAttributes)
                            {
                                moduleList.Add(configReader.GetAttribute("value"));
                            }
                        }
                        else if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "contener"))
                        {
                            if (configReader.HasAttributes)
                            {
                                contenerList.Add(configReader.GetAttribute("name"));
                            }
                        }

                    }
                    Returnable returnable = new Returnable(portList, moduleList, contenerList);
                    return returnable;

                }
                catch
                    (Exception e)
                {
                    return null;
                }
        }