public void SetState(string objXMLData, IScene ins)
{
if (!(ins is Scene))
return;
Scene s = (Scene)ins;
if (objXMLData == String.Empty)
return;
IScriptModule scriptModule = null;
foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>())
{
if (sm.ScriptEngineName == s.DefaultScriptEngine)
scriptModule = sm;
else if (scriptModule == null)
scriptModule = sm;
}
if (scriptModule == null)
return;
XmlDocument doc = new XmlDocument();
try
{
doc.LoadXml(objXMLData);
}
catch (Exception) // (System.Xml.XmlException)
{
// We will get here if the XML is invalid or in unit
// tests. Really should determine which it is and either
// fail silently or log it
// Fail silently, for now.
// TODO: Fix this
//
return;
}
XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
if (rootL.Count != 1)
return;
XmlElement rootE = (XmlElement)rootL[0];
XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates");
if (dataL.Count != 1)
return;
XmlElement dataE = (XmlElement)dataL[0];
foreach (XmlNode n in dataE.ChildNodes)
{
XmlElement stateE = (XmlElement)n;
UUID itemID = new UUID(stateE.GetAttribute("UUID"));
scriptModule.SetXMLState(itemID, n.OuterXml);
}
}