Пример #1
0
        public static void AddDevice(string deviceIPAddress, string deviceName)
        {
            string configFilePath = ConfigFileManager.GetConfigurationFilePath();

            var xmlConfigFile = ConfigFileManager.LoadConfigFile(configFilePath);

            XmlNode xNodeServer = xmlConfigFile.CreateNode(XmlNodeType.Element, "Device", string.Empty);

            XmlAttribute xAttributeSite = xmlConfigFile.CreateAttribute("IPAddress");

            xAttributeSite.Value = deviceIPAddress;
            xNodeServer.Attributes.Append(xAttributeSite);

            XmlAttribute xAttributeName = xmlConfigFile.CreateAttribute("Name");

            xAttributeName.Value = deviceName;
            xNodeServer.Attributes.Append(xAttributeName);

            xmlConfigFile.GetElementsByTagName("Devices")[0]
            .InsertAfter(xNodeServer, xmlConfigFile.GetElementsByTagName("Devices")[0].LastChild);

            xmlConfigFile.Save(configFilePath);
        }
Пример #2
0
        public static List <Device> GetDevices()
        {
            string filePath = GetConfigurationFilePath();

            if (!File.Exists(filePath))
            {
                ConfigFileManager.CreateConfigFile(filePath);
            }

            var devices = new List <Device>();

            var doc = ConfigFileManager.LoadConfigFile(filePath);

            XmlNode xServersNode = doc.DocumentElement.ChildNodes[1];

            foreach (XmlNode node in xServersNode.ChildNodes)
            {
                Device sdk = Device.GetDeviceFromXmlNode(node);
                devices.Add(sdk);
            }

            return(devices);
        }
Пример #3
0
        public static void AddSDK(string sdkPath, string sdkName)
        {
            string configFilePath = ConfigFileManager.GetConfigurationFilePath();

            var xmlConfigFile = ConfigFileManager.LoadConfigFile(configFilePath);

            XmlNode xNodeServer = xmlConfigFile.CreateNode(XmlNodeType.Element, "SDK", string.Empty);

            XmlAttribute xAttributeSite = xmlConfigFile.CreateAttribute("Path");

            xAttributeSite.Value = sdkPath;
            xNodeServer.Attributes.Append(xAttributeSite);

            XmlAttribute xAttributeName = xmlConfigFile.CreateAttribute("Name");

            xAttributeName.Value = sdkName;
            xNodeServer.Attributes.Append(xAttributeName);

            xmlConfigFile.GetElementsByTagName("SDKs")[0]
            .InsertAfter(xNodeServer, xmlConfigFile.GetElementsByTagName("SDKs")[0].LastChild);

            xmlConfigFile.Save(configFilePath);
        }
Пример #4
0
        public static List <SDK> GetSDKs()
        {
            string filePath = GetConfigurationFilePath();

            if (!File.Exists(filePath))
            {
                ConfigFileManager.CreateConfigFile(filePath);
            }

            var sdks = new List <SDK>();

            var doc = ConfigFileManager.LoadConfigFile(filePath);

            XmlNode xServersNode = doc.DocumentElement.FirstChild;

            foreach (XmlNode node in xServersNode.ChildNodes)
            {
                SDK sdk = SDK.GetSDKFromXmlNode(node);
                sdks.Add(sdk);
            }

            return(sdks);
        }