Пример #1
0
        public async void SelectedRuleModelChanged()
        {
            AllowEdit    = false;
            SelectedRule = null;
            var _t = new Rule();

            if (SelectedRuleModel != null)
            {
                var _rule = RuleCollection.ToList().Where(x => x.InstanceID == SelectedRuleModel.InstanceID);

                if (_rule.Count() == 1)
                {
                    _t       = _rule.First();
                    _t.IsNew = false;
                    await _t.GetAdditionalInfo();
                }
                else if (!_rule.Any())
                {
                    _t = new Rule()
                    {
                        IsNew               = true,
                        DisplayName         = SelectedRuleModel.DisplayName,
                        Description         = SelectedRuleModel.Description,
                        DisplayGroup        = SelectedRuleModel.DisplayGroup,
                        Action              = Enum.Parse <Enumerations.Action>(SelectedRuleModel.Action),
                        Enabled             = Enum.Parse <Enumerations.Enabled>(SelectedRuleModel.Enabled),
                        Direction           = Enum.Parse <Enumerations.Direction>(SelectedRuleModel.Direction),
                        EdgeTraversalPolicy = Enum.Parse <Enumerations.EdgeTraversalPolicy>(SelectedRuleModel.EdgeTraversalPolicy),
                        PrimaryStatus       = Enum.Parse <Enumerations.PrimaryStatus>(SelectedRuleModel.PrimaryStatus),
                        InterfaceType       = Enum.Parse <Enumerations.InterfaceType>(SelectedRuleModel.InterfaceType),
                        Program             = SelectedRuleModel.Program,
                        LocalAddress        = SelectedRuleModel.LocalAddress,
                        RemoteAddress       = SelectedRuleModel.RemoteAddress,
                        LocalPort           = SelectedRuleModel.LocalPort,
                        RemotePort          = SelectedRuleModel.RemotePort,
                        Protocol            = Enum.Parse <Enumerations.Protocol>(SelectedRuleModel.Protocol),
                        Profile             = Enum.Parse <Enumerations.Profile>(SelectedRuleModel.Profile)
                    };
                }

                SelectedRule = _t;
            }

            AllowEdit = true;
        }