private static NameValueItem CreateNameValueItem(Dictionary <string, List <NameValueItem> > dictNameValues, Stack <NameValueItem> sItemStack, NameValueItem nviCurrentItem, string strName, string strValue) { if (nviCurrentItem == null) { nviCurrentItem = new NameValueItem(strName, strValue); if (!dictNameValues.ContainsKey(strName)) { dictNameValues.Add(strName, new List <NameValueItem>()); } dictNameValues[strName].Add(nviCurrentItem); } else { NameValueItem nvi = new NameValueItem(strName, strValue); nviCurrentItem.AddChildItem(nvi); sItemStack.Push(nviCurrentItem); nviCurrentItem = nvi; } return(nviCurrentItem); }
/// <summary> /// Converts an array of MAC addresses to name value items with the given name /// </summary> /// <param name="strName">The name of the name value items</param> /// <param name="arAddresses">The MAC addresses which should be converted to the valuees of the name value items</param> /// <returns>An array of name value items which represents the given parameters</returns> public static NameValueItem[] ConvertToNameValueItems(string strName, MACAddress[] arAddresses) { NameValueItem[] nvi = new NameValueItem[arAddresses.Length]; for (int iC1 = 0; iC1 < nvi.Length; iC1++) { nvi[iC1] = new NameValueItem(strName, arAddresses[iC1].ToString()); } return(nvi); }
/// <summary> /// Converts an array of subnetmasks to name value items with the given name /// </summary> /// <param name="strName">The name of the name value items</param> /// <param name="arMasks">The subnetmasks which should be converted to the valuees of the name value items</param> /// <returns>An array of name value items which represents the given parameters</returns> public static NameValueItem[] ConvertToNameValueItems(string strName, Subnetmask[] arMasks) { NameValueItem[] nvi = new NameValueItem[arMasks.Length]; for (int iC1 = 0; iC1 < nvi.Length; iC1++) { nvi[iC1] = new NameValueItem(strName, arMasks[iC1].ToString()); } return(nvi); }
public override eExNetworkLibrary.TrafficModifiers.StreamModification.HTTP.HTTPStreamModifierAction Create(eExNLML.IO.NameValueItem nviConfigurationRoot) { ImageFlipper imgFlip = (ImageFlipper)Create(); imgFlip.RotateFlipType = (System.Drawing.RotateFlipType)ConfigurationParser.ConvertToInt(nviConfigurationRoot["imageOperation"])[0]; return imgFlip; }
/// <summary> /// Loads the configuration from the given XmlReader /// </summary> /// <param name="xmw">The XmlReader to load the configuration for</param> /// <param name="eEnviornment">The environment to associate with the traffic handler</param> public void LoadConfiguration(XmlReader xmw, IEnvironment eEnviornment) { Dictionary <string, List <NameValueItem> > dictNameValues = new Dictionary <string, List <NameValueItem> >(); Stack <NameValueItem> sItemStack = new Stack <NameValueItem>(); NameValueItem nviCurrentItem = null; bool bBreak = false; string strName = null; string strValue = null; while (!bBreak) { switch (xmw.NodeType) { case XmlNodeType.Element: if (xmw.Name == XMLConfigurationProperty) { if (strName != null) { nviCurrentItem = CreateNameValueItem(dictNameValues, sItemStack, nviCurrentItem, strName, strValue); } strName = xmw.GetAttribute("name"); strValue = ""; } else { bBreak = true; } break; case XmlNodeType.Text: if (strName != null) { strValue = xmw.Value; nviCurrentItem = CreateNameValueItem(dictNameValues, sItemStack, nviCurrentItem, strName, strValue); strName = null; strValue = null; } break; case XmlNodeType.EndElement: if (xmw.Name == XMLConfigurationProperty) { if (strName != null) { //This is an empty item. nviCurrentItem = CreateNameValueItem(dictNameValues, sItemStack, nviCurrentItem, strName, strValue); strName = null; strValue = null; } if (sItemStack.Count > 0) { nviCurrentItem = sItemStack.Pop(); } else { nviCurrentItem = null; } } break; } if (!bBreak && !xmw.Read()) { bBreak = true; } } Dictionary <string, NameValueItem[]> dictNameValueArray = new Dictionary <string, NameValueItem[]>(); foreach (string str in dictNameValues.Keys) { dictNameValueArray.Add(str, dictNameValues[str].ToArray()); } ParseConfiguration(dictNameValueArray, eEnviornment); }
public override eExNetworkLibrary.TrafficModifiers.StreamModification.HTTP.HTTPStreamModifierCondition Create(eExNLML.IO.NameValueItem nviConfigurationRoot) { HeaderCondition hcCondition = (HeaderCondition)Create(); hcCondition.Pattern = ConfigurationParser.ConvertToString(nviConfigurationRoot["pattern"])[0]; hcCondition.Header = ConfigurationParser.ConvertToString(nviConfigurationRoot["header"])[0]; hcCondition.EvaluateRequestForResponse = ConfigurationParser.ConvertToBools(nviConfigurationRoot["evaluateRequestForResponse"])[0]; return(hcCondition); }
/// <summary> /// Adds a child configuration item /// </summary> /// <param name="nvi">The child configuration item to add</param> public void AddChildItem(NameValueItem nvi) { arChilds.Add(nvi); }