Ejemplo n.º 1
0
        static RefreshableComponent ParseRefreshableComponents(string refreshList)
        {
            if (String.IsNullOrEmpty(refreshList))
            {
                return(RefreshableComponent.All);
            }

            if (refreshList.IndexOf(',') == -1)
            {
                return(ParseSingleComponent(refreshList));
            }

            var allParsedComponents = RefreshableComponent.None;
            var refreshListArray    = refreshList.Split(',');

            foreach (var c in refreshListArray)
            {
                RefreshableComponent parsed = ParseSingleComponent(c);
                if (parsed != RefreshableComponent.None)
                {
                    allParsedComponents |= parsed;
                }
            }

            return(allParsedComponents);


            RefreshableComponent ParseSingleComponent(string component)
            {
                if (String.Compare("sdk", component, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(RefreshableComponent.AndroidSDK);
                }

                if (String.Compare("ndk", component, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(RefreshableComponent.AndroidNDK);
                }

                return(RefreshableComponent.None);
            }
        }
Ejemplo n.º 2
0
        public ToolboxNode(bool isEdgeServerRoleOnly) : base(true)
        {
            ToolboxNode < > 4__this = this;
            base.DisplayName        = Strings.Toolbox;
            base.Icon      = Icons.Toolbox;
            base.HelpTopic = HelpId.ToolboxNode.ToString();
            base.ViewDescriptions.Add(ExchangeFormView.CreateViewDescription(typeof(ToolboxResultPane)));
            RefreshableComponent refreshableComponent = new RefreshableComponent();

            base.DataSource = refreshableComponent;
            refreshableComponent.DoRefreshWork += delegate(object sender, RefreshRequestEventArgs e)
            {
                DataList <Tool> dataList     = new DataList <Tool>();
                DataProvider    dataProvider = new RegistryDataProvider(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\AdminTools\\Toolbox", ConfigurationContext.Setup.InstallPath);
                dataProvider.Query();
                for (int i = 0; i < dataProvider.Tools.Count; i++)
                {
                    Tool tool = dataProvider.Tools[i];
                    if (tool.Name != string.Empty && Tool.IsToolDuplicate(dataList, tool))
                    {
                        tool.ValidTool = false;
                        tool.AddErrorMessage(Strings.DuplicateTool(tool.DataSource));
                    }
                    else if (!isEdgeServerRoleOnly || !tool.NonEdgeTool)
                    {
                        dataList.Add(tool);
                    }
                }
                e.Result = dataList;
            };
            refreshableComponent.RefreshCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                if (e.Cancelled)
                {
                    return;
                }
                DataList <Tool> dataList = (DataList <Tool>)e.Result;
                this.ValidTools.Clear();
                DataList <Tool> dataList2 = new DataList <Tool>();
                for (int i = 0; i < dataList.Count; i++)
                {
                    if (dataList[i].ValidTool)
                    {
                        this.ValidTools.Add(dataList[i]);
                    }
                    else
                    {
                        dataList2.Add(dataList[i]);
                    }
                }
                if (dataList2.Count > 0)
                {
                    List <WorkUnit> list = new List <WorkUnit>();
                    for (int j = 0; j < dataList2.Count; j++)
                    {
                        WorkUnit workUnit = new WorkUnit();
                        workUnit.Text = dataList2[j].DataSource;
                        Exception ex = new Exception(dataList2[j].ErrorMessage);
                        workUnit.Errors.Add(new ErrorRecord(ex, LocalizedException.GenerateErrorCode(ex).ToString("X"), ErrorCategory.InvalidOperation, null));
                        workUnit.Status = WorkUnitStatus.Failed;
                        list.Add(workUnit);
                    }
                    UIService.ShowError(Strings.ErrorDialogMessage, string.Empty, list.ToArray(), base.ShellUI);
                }
            };
        }