Adding Xml serialization of Dictionary<string, object> where object
is either another Dictionary<string, object> or a value that is convertible to a string.remotes/origin/0.6.7-post-fixes
parent
5f9a193b43
commit
97ebdd4607
|
@ -183,5 +183,77 @@ namespace OpenSim.Server.Base
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string BuildQueryString(Dictionary<string, string> data)
|
||||||
|
{
|
||||||
|
string qstring = String.Empty;
|
||||||
|
|
||||||
|
foreach(KeyValuePair<string, string> kvp in data)
|
||||||
|
{
|
||||||
|
string part;
|
||||||
|
if (kvp.Value != String.Empty)
|
||||||
|
{
|
||||||
|
part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
|
||||||
|
"=" + System.Web.HttpUtility.UrlEncode(kvp.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
part = System.Web.HttpUtility.UrlEncode(kvp.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qstring != String.Empty)
|
||||||
|
qstring += "&";
|
||||||
|
|
||||||
|
qstring += part;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string BuildXmlResponse(Dictionary<string, object> data)
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
|
||||||
|
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
|
||||||
|
"", "");
|
||||||
|
|
||||||
|
doc.AppendChild(xmlnode);
|
||||||
|
|
||||||
|
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
|
||||||
|
"");
|
||||||
|
|
||||||
|
doc.AppendChild(rootElement);
|
||||||
|
|
||||||
|
BuildXmlData(rootElement, data);
|
||||||
|
|
||||||
|
return doc.InnerXml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void BuildXmlData(XmlElement parent, Dictionary<string, object> data)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, object> kvp in data)
|
||||||
|
{
|
||||||
|
XmlElement elem = parent.OwnerDocument.CreateElement("",
|
||||||
|
kvp.Key, "");
|
||||||
|
|
||||||
|
if (kvp.Value is Dictionary<string, object>)
|
||||||
|
{
|
||||||
|
XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
|
||||||
|
"type", "");
|
||||||
|
type.Value = "List";
|
||||||
|
|
||||||
|
elem.Attributes.Append(type);
|
||||||
|
|
||||||
|
BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elem.AppendChild(parent.OwnerDocument.CreateTextNode(
|
||||||
|
kvp.Value.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.AppendChild(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1213,6 +1213,7 @@
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
<Reference name="OpenSim.Framework.Communications"/>
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
<Reference name="OpenSim.Framework.Console"/>
|
||||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||||
|
<Reference name="OpenSim.Server.Base"/>
|
||||||
<Reference name="Nini.dll" />
|
<Reference name="Nini.dll" />
|
||||||
<Reference name="log4net.dll"/>
|
<Reference name="log4net.dll"/>
|
||||||
<Reference name="XMLRPC.dll" />
|
<Reference name="XMLRPC.dll" />
|
||||||
|
|
Loading…
Reference in New Issue