コード例 #1
0
        public ProxyTestableViewModel()
        {
            TestProxy = AsyncCommand.Create((parameter, token) =>
            {
                Url url    = new Url(parameter as string ?? "");
                TestResult = new SiteTestResultViewModel()
                {
                    Model = new SiteProxyTestResult(HttpStatusCode.Gone, "", -1, SiteProxyTestStatus.Testing)
                };
                return(SiteProxyTester.RunTest(m_model, url, token));
            });

            TestProxy.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Execution")
                {
                    if (m_testProxyExecution != null)
                    {
                        m_testProxyExecution.PropertyChanged -= TaskCompletionNotifierPropertyChangedHandler;
                    }

                    m_testProxyExecution = TestProxy.Execution;

                    m_testProxyExecution.PropertyChanged += TaskCompletionNotifierPropertyChangedHandler;
                }
            };

            GetLocation = AsyncCommand.Create((parameter, token) =>
            {
                Location = "pending...";
                return(IpGeolocation.GetLocation(m_model, token));
            });

            GetLocation.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Execution")
                {
                    if (m_getLocationExecution != null)
                    {
                        m_getLocationExecution.PropertyChanged -=
                            GetLocationTaskCompletionNotifierPropertyChangedHandler;
                    }
                }

                m_getLocationExecution = GetLocation.Execution;

                m_getLocationExecution.PropertyChanged += GetLocationTaskCompletionNotifierPropertyChangedHandler;
            };
        }