public static Dictionary <string, FwkData> ReadDataNodes(XmlNode node) { XmlNodeList xmlNodes = node.SelectNodes("data"); // Console.WriteLine("Total number of data nodes found = " + xmlNodes.Count); if (xmlNodes != null) { Dictionary <string, FwkData> dataNodes = new Dictionary <string, FwkData>(); foreach (XmlNode xmlNode in xmlNodes) { XmlAttribute tmpattr = xmlNode.Attributes["name"]; string name; if (tmpattr != null) { name = tmpattr.Value; } else { throw new IllegalArgException("The xml file passed has an unknown format"); } //Console.WriteLine("xmlNode.FirstChild.Name = " + xmlNode.FirstChild.Name); if (xmlNode.FirstChild == null || xmlNode.FirstChild.NodeType == XmlNodeType.Text) { object data = xmlNode.InnerText; // Console.WriteLine("Going to construct FwkData with data = " + data.ToString() + // " data2 = null " + " datakind = " + DataKind.String.ToString()); FwkData td = new FwkData(data, null, DataKind.String); dataNodes[name] = td; } else if (xmlNode.FirstChild.Name == "snippet") { string regionName; if (xmlNode.FirstChild.FirstChild.Name == "region") { XmlAttribute nameattr = xmlNode.FirstChild.FirstChild.Attributes["name"]; regionName = nameattr.Value; // Now collect the region atributes XmlNode attrnode = xmlNode.FirstChild.FirstChild.FirstChild; Apache.Geode.Client.Properties <string, string> rattr = Apache.Geode.Client.Properties <string, string> .Create <string, string>(); //AttributesFactory af = new AttributesFactory(); if (attrnode.Name == "region-attributes") { XmlAttributeCollection attrcoll = attrnode.Attributes; if (attrcoll != null) { foreach (XmlAttribute eachattr in attrcoll) { rattr.Insert(eachattr.Name, eachattr.Value); //SetThisAttribute(eachattr.Name, eachattr, af); } } if (attrnode.ChildNodes != null) { foreach (XmlNode tmpnode in attrnode.ChildNodes) { rattr.Insert(tmpnode.Name, tmpnode.Value); //SetThisAttribute(tmpnode.Name, tmpnode, af); } } Apache.Geode.Client.DataOutput dout = new Apache.Geode.Client.DataOutput(); //RegionAttributes rattr = af.CreateRegionAttributes(); rattr.ToData(dout); // Console.WriteLine("Going to construct FwkData with region = " + regionName + // " data2 = region attributes" + " datakind = " + DataKind.Region.ToString()); FwkData td = new FwkData(regionName, dout.GetBuffer(), DataKind.Region); dataNodes[name] = td; } else { throw new IllegalArgException("The xml file passed has an unknown format"); } } else if (xmlNode.FirstChild.FirstChild.Name == "pool") { XmlAttribute nameattr = xmlNode.FirstChild.FirstChild.Attributes["name"]; String poolName = nameattr.Value; // Now collect the pool atributes Apache.Geode.Client.Properties <string, string> prop = Apache.Geode.Client.Properties <string, string> .Create <string, string>(); XmlAttributeCollection attrcoll = xmlNode.FirstChild.FirstChild.Attributes; if (attrcoll != null) { foreach (XmlAttribute eachattr in attrcoll) { prop.Insert(eachattr.Name, eachattr.Value); } Apache.Geode.Client.DataOutput dout = new Apache.Geode.Client.DataOutput(); prop.ToData(dout); FwkData td = new FwkData(poolName, dout.GetBuffer(), DataKind.Pool); dataNodes[name] = td; } else { throw new IllegalArgException("The xml file passed has an unknown format"); } } else { throw new IllegalArgException("The xml file passed has an unknown format"); } } else if (xmlNode.FirstChild.Name == "list") { List <string> tmplist = new List <string>(); XmlNode listNode = xmlNode.FirstChild; if (listNode.FirstChild != null) { bool isOneOf = false; if (listNode.FirstChild.Name == "oneOf") { isOneOf = true; listNode = listNode.FirstChild; } XmlNodeList tmpListNodes = listNode.ChildNodes; foreach (XmlNode itemnode in tmpListNodes) { if (itemnode.Name == "item") { tmplist.Add(itemnode.InnerText); //Console.WriteLine("Adding the value " + itemnode.InnerText + " to the list"); } else { throw new IllegalArgException("The xml file passed has an unknown node " + itemnode.Name + " in data-list"); } } //Console.WriteLine("Going to construct FwkData list data: oneof = " + isOneOf.ToString() + " datakind = " + DataKind.List.ToString()); FwkData td = new FwkData(tmplist, isOneOf, DataKind.List); dataNodes[name] = td; } } else if (xmlNode.FirstChild.Name == "range") { XmlAttributeCollection rangeAttr = xmlNode.FirstChild.Attributes; string lowmarkstr = rangeAttr["low"].Value; string highmarkstr = rangeAttr["high"].Value; int lowmark = int.Parse(lowmarkstr); int highmark = int.Parse(highmarkstr); //Console.WriteLine("Going to construct FwkData Range datakind = " + DataKind.Range.ToString() + " high = " + highmark + " low = " + lowmark); FwkData td = new FwkData(lowmark, highmark, DataKind.Range); dataNodes[name] = td; } else if (xmlNode.FirstChild.Name == "oneof") { XmlNodeList itemlist = xmlNode.FirstChild.ChildNodes; List <string> opItemList = new List <string>(); foreach (XmlNode tmpitem in itemlist) { if (tmpitem.Name == "item") { opItemList.Add(tmpitem.InnerText); } } FwkData td = new FwkData(opItemList, true, DataKind.List); dataNodes[name] = td; } else { throw new IllegalArgException("The xml file passed has an unknown child: " + xmlNode.FirstChild.Name + " ; number of childnodes: " + (xmlNode.ChildNodes == null ? XmlNodeType.None : xmlNode.FirstChild.NodeType)); } } return(dataNodes); } return(null); }
/// <summary> /// Write the complex number to the <see cref="DataOutput" /> stream. /// </summary> /// <param name="output">The <c>DataOutput</c> stream.</param> public void ToData(Apache.Geode.Client.DataOutput output) { output.WriteDouble(m_real); output.WriteDouble(m_imaginary); }