Esempio n. 1
0
        public void  RenameRule(IResource rule, string newName)
        {
            #region Preconditions
            if (rule == null)
            {
                throw new ArgumentNullException("rule", "ExpirationRuleManager -- Input rule resource is null.");
            }

            if (rule.Type != FilterManagerProps.RuleResName || !rule.HasProp("IsExpirationFilter"))
            {
                throw new InvalidOperationException("ExpirationRuleManager -- input resource is not a TrayIcon rule.");
            }

            if (String.IsNullOrEmpty(newName))
            {
                throw new ArgumentNullException("newName", "ExpirationRuleManager -- New name for a rule is null or empty.");
            }
            #endregion Preconditions

            if (FilterRegistry.FindRuleByName(newName, "IsExpirationFilter") != null)
            {
                throw new ArgumentException("ExpirationRuleManager -- An action rule with new name already exists.");
            }

            new ResourceProxy(rule).SetProp(Core.Props.Name, newName);
        }