A simple implementation similar to XElement.
Ejemplo n.º 1
0
        /// <summary>
        /// Sets the value of a new child element.
        /// </summary>
        /// <param name="elementName">The element name.</param>
        /// <param name="value">The value of the new element.</param>
        public void SetElementValue(string elementName, string value)
        {
            SimpleXElement child = new SimpleXElement(elementName);

            child.Value = value;
            Add(child);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new SimpleXElement.
        /// </summary>
        /// <param name="xml">XML content.</param>
        /// <returns>Returns a new instance of the element and children.</returns>
        public static SimpleXElement Parse(string xml)
        {
            SimpleXElement sxe = new SimpleXElement();

            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                sxe.ParseInternal(reader, true);
            }
            return(sxe);
        }
Ejemplo n.º 3
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();
        }
        protected override void ProcessResponse()
        {
            if (Exception == null)
            {
                try
                {
                    SetResult(SimpleXElement.Parse(ResponseString));
                }
                catch (Exception exception)
                {
                    Exception = exception;
                }
            }

            base.ProcessResponse();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a child element to the simple element instance.
 /// </summary>
 /// <param name="child">The child element instance.</param>
 public void Add(SimpleXElement child)
 {
     _children.Add(child);
 }
 /// <summary>
 /// Adds pending output for the next result.
 /// </summary>
 /// <param name="element">The element to wrap in an Output element.</param>
 private void AddPendingOutput(SimpleXElement element)
 {
     SimpleXElement output = CreateElement("Output");
     output.Add(element);
     _pendingElements.Add(output);
 }
            /// <summary>
            /// Creates the initial results document and its XElements.
            /// </summary>
            private void CreateInitialDocument()
            {
                TestRun = CreateElement("TestRun");

                TestRunConfiguration = CreateElement("TestSettings");
                TestRun.Add(TestRunConfiguration);

                ResultSummary = CreateElement("ResultSummary");
                Counters = CreateElement("Counters");
                ResultSummary.Add(Counters);
                TestRun.Add(ResultSummary);

                Times = CreateElement("Times");
                TestRun.Add(Times);

                TestDefinitions = CreateElement("TestDefinitions");
                TestRun.Add(TestDefinitions);

                TestLists = CreateElement("TestLists");
                TestRun.Add(TestLists);

                TestEntries = CreateElement("TestEntries");
                TestRun.Add(TestEntries);

                Results = CreateElement("Results");
                TestRun.Add(Results);

                RunOutcome = TestOutcome.NotExecuted;
            }
 /// <summary>
 /// Sets the value of a new child element.
 /// </summary>
 /// <param name="elementName">The element name.</param>
 /// <param name="value">The value of the new element.</param>
 public void SetElementValue(string elementName, string value)
 {
     SimpleXElement child = new SimpleXElement(elementName);
     child.Value = value;
     Add(child);
 }
 /// <summary>
 /// Creates a new SimpleXElement.
 /// </summary>
 /// <param name="xml">XML content.</param>
 /// <returns>Returns a new instance of the element and children.</returns>
 public static SimpleXElement Parse(string xml)
 {
     SimpleXElement sxe = new SimpleXElement();
     using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
     {
         sxe.ParseInternal(reader, true);
     }
     return sxe;
 }
 /// <summary>
 /// Adds a child element to the simple element instance.
 /// </summary>
 /// <param name="child">The child element instance.</param>
 public void Add(SimpleXElement child)
 {
     _children.Add(child);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the result.
 /// </summary>
 /// <param name="result">The LINQ element for the result.</param>
 protected void SetResult(SimpleXElement result)
 {
     _result = result;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Sets the result.
 /// </summary>
 /// <param name="result">The LINQ element for the result.</param>
 protected void SetResult(SimpleXElement result)
 {
     _result = result;
 }