예제 #1
0
        public async void OnViewProfileObjectsCommand()
        {
            var result = await Utilities.GetFirewallProfile();

            var newWin = new ObjectView();
            var obj    = ObjectViewModel.Create();

            obj.SelectedPsObject = result[0];
            newWin.DataContext   = obj;
            newWin.Show();
        }
예제 #2
0
        private async Task ShowObjectWindow(string psObjType)
        {
            PSDataCollection <PSObject> resultObjs = new PSDataCollection <PSObject>();

            switch (psObjType)
            {
            case "GetFirewallRule":
                resultObjs = await Utilities.GetFirewallRule(SelectedRule.DisplayName);

                break;

            case "GetNetFirewallPortFilter":
                resultObjs = await Utilities.GetNetFirewallPortFilter(SelectedRule.DisplayName);

                break;

            case "GetNetFirewallAddressFilter":
                resultObjs = await Utilities.GetNetFirewallAddressFilter(SelectedRule.DisplayName);

                break;

            case "GetNetFirewallApplicationFilter":
                resultObjs = await Utilities.GetNetFirewallApplicationFilter(SelectedRule.DisplayName);

                break;

            case "GetNetFirewallInterfaceTypeFilter":
                resultObjs = await Utilities.GetNetFirewallInterfaceTypeFilter(SelectedRule.DisplayName);

                break;
            }

            if (resultObjs.Count != 1)
            {
                throw new Exception("ShowObjectWindow has not returned a single object");
            }

            var newWin = new ObjectView();
            var obj    = ObjectViewModel.Create();

            obj.SelectedPsObject = resultObjs[0];
            newWin.DataContext   = obj;
            newWin.Title         = $@"Object Properties: {SelectedRule.DisplayName} {resultObjs[0].Properties["CimClass"].Value.ToString().Split(':')[1]}";
            newWin.Show();
        }