TryGetElement() public method

Attempt to process and return the root element of a successful request. Returns null if there was an Exception.
public TryGetElement ( ) : SimpleXElement
return SimpleXElement
        /// <summary>
        /// Read the run parameters.
        /// </summary>
        /// <param name="result">The service result.</param>
        private void ReadRunParameters(ServiceResult result)
        {
            SimpleXElement xe = result == null ? null : result.TryGetElement();
            if (xe != null)
            {
                Dictionary<string, string> settings = xe.Descendants("option").ToTransformedDictionary((option) => option.Attribute("name"), (option) => option.Attribute("value"));
                foreach (string key in settings.Keys)
                {
                    Settings[key] = settings[key];
                }
            }

            // Allow the other services to initialize
            base.Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Read the run parameters.
        /// </summary>
        /// <param name="result">The service result.</param>
        private void ReadRunParameters(ServiceResult result)
        {
            SimpleXElement xe = result == null ? null : result.TryGetElement();

            if (xe != null)
            {
                Dictionary <string, string> settings = xe.Descendants("option").ToTransformedDictionary((option) => option.Attribute("name"), (option) => option.Attribute("value"));
                foreach (string key in settings.Keys)
                {
                    Settings[key] = settings[key];
                }
            }

            // Allow the other services to initialize
            base.Initialize();
        }