Example #1
0
        private bool LoadConfiguration()
        {
            try
            {
                dynamic jo = JObject.Parse(File.ReadAllText(this.configFilePath));

                if (jo.configuration.host == null || jo.configuration.port == null || jo.configuration.url == null)
                {
                    jo.configuration.host = this.defaultHost;
                    jo.configuration.port = this.defaultPort;
                    jo.configuration.url  = new UriBuilder("http", this.defaultHost, this.defaultPort).ToString();
                    Logger.Warn(
                        "Some of required node options (host, port or url) are not set, Winium set them to: host={0}, port={1}, url={2}."
                        + " Note that this will not work if your node and grid aren't in the same place.",
                        jo.configuration.host,
                        jo.configuration.port,
                        jo.configuration.url);
                }

                this.registrarConfiguration = jo.configuration.ToObject <NodeRegistrarConfiguration>();

                this.data = JsonConvert.SerializeObject(jo, Formatting.Indented);

                return(true);
            }
            catch (JsonReaderException ex)
            {
                Logger.Error("Syntax error in node configuration file: {0}", ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error("Error reading node configuration: {0}", ex.Message);
                return(false);
            }
        }
        private bool LoadConfiguration()
        {
            try
            {
                dynamic jo = JObject.Parse(File.ReadAllText(this.configFilePath));

                if (jo.configuration.host == null || jo.configuration.port == null || jo.configuration.url == null)
                {
                    jo.configuration.host = this.defaultHost;
                    jo.configuration.port = this.defaultPort;
                    jo.configuration.url = new UriBuilder("http", this.defaultHost, this.defaultPort).ToString();
                    Logger.Warn(
                        "Some of required node options (host, port or url) are not set, Winium set them to: host={0}, port={1}, url={2}."
                        + " Note that this will not work if your node and grid aren't in the same place.", 
                        jo.configuration.host, 
                        jo.configuration.port, 
                        jo.configuration.url);
                }

                this.registrarConfiguration = jo.configuration.ToObject<NodeRegistrarConfiguration>();

                this.data = JsonConvert.SerializeObject(jo, Formatting.Indented);

                return true;
            }
            catch (JsonReaderException ex)
            {
                Logger.Error("Syntax error in node configuration file: {0}", ex.Message);
                return false;
            }
            catch (Exception ex)
            {
                Logger.Error("Error reading node configuration: {0}", ex.Message);
                return false;
            }
        }