Пример #1
0
        private TrafficSplitterRule LoadRule(NameValueItem nviItem, IEnvironment eEnviornment)
        {
            string strKey = nviItem["ruleKey"][0].Value;
            ISubPlugInDefinition <TrafficSplitterRule> ruleDefinition = (ISubPlugInDefinition <TrafficSplitterRule>)eEnviornment.GetPlugInByKey(strKey);

            if (ruleDefinition != null)
            {
                TrafficSplitterRule tsrRule = ruleDefinition.Create(nviItem);
                foreach (NameValueItem nviChild in nviItem["rule"])
                {
                    tsrRule.AddChildRule(LoadRule(nviChild, eEnviornment));
                }
                return(tsrRule);
            }

            return(null);
        }
        private HTTPStreamModifierCondition LoadCondition(NameValueItem nviConditionItem, IEnvironment eEnviornment)
        {
            string strKey = nviConditionItem["conditionKey"][0].Value;
            ISubPlugInDefinition <HTTPStreamModifierCondition> conditionDefinition = (ISubPlugInDefinition <HTTPStreamModifierCondition>)eEnviornment.GetPlugInByKey(strKey);

            if (conditionDefinition != null)
            {
                HTTPStreamModifierCondition htCondition = conditionDefinition.Create(nviConditionItem);
                foreach (NameValueItem nviChild in nviConditionItem["condition"])
                {
                    htCondition.AddChildRule(LoadCondition(nviChild, eEnviornment));
                }
                return(htCondition);
            }

            return(null);
        }
        private NameValueItem SaveRule(IEnvironment eEnviornment, TrafficSplitterRule trRule)
        {
            NameValueItem nviRule = null;
            ISubPlugInDefinition <TrafficSplitterRule> ruleDefinition = GetRuleDefinitionForName(eEnviornment, trRule.Name);

            if (ruleDefinition != null)
            {
                nviRule = new NameValueItem("rule", "");
                nviRule.AddChildItem(new NameValueItem("ruleKey", ruleDefinition.PluginKey));
                nviRule.AddChildRange(ruleDefinition.GetConfiguration(trRule));
                foreach (TrafficSplitterRule tsrChild in trRule.ChildRules)
                {
                    NameValueItem nvi = SaveRule(eEnviornment, tsrChild);
                    if (nvi != null)
                    {
                        nviRule.AddChildItem(nvi);
                    }
                }
            }
            return(nviRule);
        }
        private NameValueItem SaveCondition(IEnvironment eEnviornment, HTTPStreamModifierCondition cCondition)
        {
            NameValueItem nviRule = null;
            ISubPlugInDefinition <HTTPStreamModifierCondition> ispConditionDefinition = null;

            ispConditionDefinition = GetConditionefinitionForName(eEnviornment, cCondition.Name);

            if (ispConditionDefinition != null)
            {
                nviRule = new NameValueItem("condition", "");
                nviRule.AddChildItem(new NameValueItem("conditionKey", ispConditionDefinition.PluginKey));
                nviRule.AddChildRange(ispConditionDefinition.GetConfiguration(cCondition));
                foreach (HTTPStreamModifierCondition cChild in cCondition.ChildRules)
                {
                    NameValueItem nvi = SaveCondition(eEnviornment, cChild);
                    if (nvi != null)
                    {
                        nviRule.AddChildItem(nvi);
                    }
                }
            }
            return(nviRule);
        }