public void Should_work_correctly()
        {
            var source = new XmlStringSource(TestCase.Xml);

            source.Observe()
            .WaitFirstValue(5.Seconds())
            .Should()
            .BeEquivalentTo((TestCase.SettingsTree, null as Exception));
        }
        public void Should_propagate_changes_to_observers_on_external_push()
        {
            var source = new XmlStringSource("<key></key>");

            source.Push(TestCase.Xml);

            source.Observe()
            .WaitFirstValue(5.Seconds())
            .Should()
            .BeEquivalentTo((TestCase.SettingsTree, null as Exception));
        }
Пример #3
0
        /// <summary>
        /// Downloads an xml from an url.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private IXmlSource DownloadXml(string url)
        {
            // download the xml string.
            string xml = this.DownloadString(url);

            // parse the xml if it exists.
            IXmlSource source = null;

            if (!string.IsNullOrEmpty(xml))
            {
                source = new XmlStringSource(xml);
            }
            return(source);
        }
Пример #4
0
        public void SetXml(string xml)
        {
            RemoveCurrent();

            try
            {
                XmlStringSource xmlSource = new XmlStringSource(xml);
                using (Parser parser = new Parser(xmlSource.GetStream()))
                {
                    m_CurrentElement = parser.Parse(this.View);
                }

                m_CurrentElement.Show();

                m_CurrentElement.DrawDebugOutlines = m_DebugOutlines;

                if (m_CurrentElement is Window || m_CurrentElement is ToolWindow)
                {
                    if (m_CurrentElement is Window)
                    {
                        ((Window)m_CurrentElement).IsDraggingEnabled = false;
                    }
                    else
                    {
                        ((ToolWindow)m_CurrentElement).IsDraggingEnabled = false;
                    }

                    m_CurrentElement.MaximumSize = this.View.ActualSize;
                    m_CurrentElement.Position    = View.LocalPosToCanvas(Point.Zero);
                }

                if (Exception != null)
                {
                    m_ExceptionEventArgs.Exception = null;
                    Exception(View, m_ExceptionEventArgs);
                }
            }
            catch (Exception ex)
            {
                if (Exception != null)
                {
                    m_ExceptionEventArgs.Exception = ex;
                    Exception(View, m_ExceptionEventArgs);
                }

                RemoveCurrent();
            }
        }