Esempio n. 1
0
        /// <summary>
        /// Sets a value for the given key and value name
        /// </summary>
        /// <param name="value"></param>
        /// <param name="action">Action to perform when setting the value</param>
        public override bool SetValue(FirewallRule value, object action)
        {
            switch (value)
            {
            case FirewallRule.None:
            {
                FirewallHelper.EnableFirewallForExecutingApplication(programName, true);
                break;
            }

            case FirewallRule.Exist:
            {
                FirewallHelper.EnableFirewallForExecutingApplication(programName, false);
                break;
            }

            case FirewallRule.Enabled:
            {
                FirewallHelper.DisableFirewallForExecutingApplication(programName);
                break;
            }

            default:
            {
                throw new ArgumentException("Value is not a valid enum value.", "value");
            }
            }

            return(true);
        }