コード例 #1
0
        private void LoadComponents([NotNull] string response, [NotNull] ExecuteResult executeResult, bool firstTime, [CanBeNull] Action completed)
        {
            Debug.ArgumentNotNull(response, nameof(response));
            Debug.ArgumentNotNull(executeResult, nameof(executeResult));

            DataService.DisableLoginErrorMessage = false;

            if (executeResult.Error != null && executeResult.Error.Message == @"No Service")
            {
                RenderComponents();

                if (!firstTime)
                {
                    AppHost.MessageBox("Got a \"No Service\" error.\n\nPlease check that the connection is correct.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                if (completed != null)
                {
                    completed();
                }

                return;
            }

            if (!DataService.HandleExecute(response, executeResult, false))
            {
                RenderComponents();
                if (completed != null)
                {
                    completed();
                }

                return;
            }

            if (string.IsNullOrEmpty(response))
            {
                RenderComponents();
                if (completed != null)
                {
                    completed();
                }

                return;
            }

            var doc  = XDocument.Parse(response);
            var root = doc.Root;

            if (root == null)
            {
                return;
            }

            foreach (var element in root.Elements(@"component"))
            {
                var info = new ServerComponentInfo
                {
                    Name    = element.GetAttributeValue("name"),
                    Version = element.GetAttributeValue("version")
                };

                ServerComponents.Add(info);
            }

            RenderComponents();

            if (completed != null)
            {
                completed();
            }
        }