Exemplo n.º 1
0
        public IResource  CloneRule(IResource sourceRule, string newName)
        {
            #region Preconditions
            if (!sourceRule.HasProp("IsFormattingFilter"))
            {
                throw new InvalidOperationException("FormattingRuleManager -- input resource is not a Formatting rule.");
            }

            IResource res = FindRule(newName);
            if (res != null)
            {
                throw new AmbiguousMatchException("FormattingRuleManager -- A Formatting rule with such name already exists.");
            }
            #endregion Preconditions

            ResourceProxy newRule = ResourceProxy.BeginNewResource(FilterManagerProps.ViewCompositeResName);
            FilterRegistry.CloneView(sourceRule, newRule, newName);
            CloneFormatting(sourceRule, newRule.Resource);

            return(newRule.Resource);
        }
Exemplo n.º 2
0
        public IResource  CloneRule(IResource source, string newName)
        {
            #region Preconditions
            if (!source.HasProp("IsTrayIconFilter"))
            {
                throw new InvalidOperationException("TrayIconManager -- input resource is not a TrayIcon rule.");
            }

            IResource res = FindRule(newName);
            if (res != null)
            {
                throw new AmbiguousMatchException("TrayIconManager -- TrayIcon rule with such name already exists.");
            }
            #endregion Preconditions

            ResourceProxy newRule = GetRuleProxy(null);
            FilterRegistry.CloneView(source, newRule, newName);
            CloneStaticInfo(source, newRule.Resource);
            RegisterIconWatcher(newRule.Resource);

            return(newRule.Resource);
        }