/// <summary> /// The function is used to read the script xml /// </summary> /// <param name="objects"></param> public void convert(ObjectSpace objects) { IEnumerator<xmlObject> iter = objects.getIter(); String temp; ScriptData script; while (iter.MoveNext()) { script = new ScriptData(); temp = iter.Current.findValueOfProperty("alias"); if (temp != null) { script.Alias = temp; } temp = iter.Current.findValueOfProperty("file"); if (temp != null) { script.File = temp; } //Check if there is a file name and alias if ((script.Alias != "") && (script.File != "")) { Log.getInstance().log("@Folder:Scripts, Class:ScriptKeeper, Log Type: Error, Line No: 121, " + "Scriptkeeper : Empty script file missing alias or file "); } //Load the script addScript(script); } }
/// <summary> /// The contents of the script file are loaded as a string /// If the script file is not found , it will close the game /// </summary> /// <param name="alias">The alias of the script</param> /// <param name="file">The file name</param> public void addScript(ScriptData script) { try { //Load the script as a string FileStream fs = File.Open(script.File, FileMode.Open, FileAccess.Read); TextReader reader = new StreamReader(fs); script.Data = reader.ReadToEnd(); scripts.Add(script.Alias,script); reader.Close(); } catch (Exception e) { Log.getInstance().log("@Folder:Scripts, Class:ScriptKeeper, Log Type: Error, Line No: 69, " + "Script Keeper :The script file " + script.File + "could not be loaded. Exception " + e.ToString()); System.Console.WriteLine(e); System.Environment.Exit(-1); } }