Exemple #1
0
        public static IResource Template2Action(IResource template, object param, string representation)
        {
            if (template.Type != FilterManagerProps.RuleActionTemplateResName)
            {
                throw new ArgumentException("FilterRegistry -- Invalid type of parameter - RuleActionTemplate is expected");
            }

            IResource   action;
            ConditionOp op = (ConditionOp)template.GetProp("ConditionOp");

            if (op == ConditionOp.In)
            {
                if (param is IResourceList)
                {
                    action = FilterRegistry.RegisterRuleActionProxy(template, (IResourceList)param);
                }
                else
                if (param is string)
                {
                    action = FilterRegistry.RegisterRuleActionProxy(template, (string)param);
                }
                else
                {
                    throw new ArgumentException("Illegal parameter type for the operation - string or Resource List expected");
                }
            }
            else
            if (op == ConditionOp.Eq)
            {
                if (param is string)
                {
                    action = FilterRegistry.RegisterRuleActionProxy(template, (string)param);
                }
                else
                {
                    throw new ArgumentException("Illegal parameter type for the operation - string expected");
                }
            }
            else
            {
                throw new InvalidOperationException("Not all Operations are supported now");
            }

            if (!String.IsNullOrEmpty(representation))
            {
                new ResourceProxy(action).SetProp("SurfaceConditionVal", representation);
            }
            return(action);
        }