public static void SaveDatabase(string fileLocation, TalkerMakerDatabase theDatabase) { using (StreamWriter sw = new StreamWriter(fileLocation)) { string output = JsonConvert.SerializeObject(theDatabase); sw.WriteLine(output); } }
public static void ExportToXML(string fileLocation, TalkerMakerDatabase theDatabase) { string xmlOutput = $@"<?xml version=""1.0"" encoding=""utf-16""?> <ChatMapperProject xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" Title=""{theDatabase.Title}"" Version=""{theDatabase.Version}"" Author=""{theDatabase.Author}"" EmphasisColor1Label="""" EmphasisColor1=""#ffffff"" EmphasisStyle1=""---"" EmphasisColor2Label="""" EmphasisColor2=""#ff0000"" EmphasisStyle2=""---"" EmphasisColor3Label="""" EmphasisColor3=""#00ff00"" EmphasisStyle3=""---"" EmphasisColor4Label="""" EmphasisColor4=""#0000ff"" EmphasisStyle4=""---""> <Description>{theDatabase.Description}</Description> <UserScript /> <Assets><Actors>"; Console.WriteLine("Writing Actors"); foreach (Actor actor in theDatabase.Actors) { xmlOutput += actor.ToXML(); } xmlOutput += "</Actors><Items>"; Console.WriteLine("Writing Items"); foreach (Item item in theDatabase.Items) { xmlOutput += item.ToXML(); } xmlOutput += "</Items><Locations>"; Console.WriteLine("Writing Locations"); foreach (Location location in theDatabase.Locations) { xmlOutput += location.ToXML(); } xmlOutput += "</Locations><Conversations>"; Console.WriteLine("Writing Conversations"); foreach (Conversation conversation in theDatabase.Conversations) { xmlOutput += conversation.ToXML(); } xmlOutput += "</Conversations><UserVariables>"; Console.WriteLine("Writing Variables"); foreach (UserVariable variable in theDatabase.Variables) { xmlOutput += variable.ToXML(); } xmlOutput += "</UserVariables></Assets></ChatMapperProject>"; using (StreamWriter sw = new StreamWriter(fileLocation)) { sw.WriteLine(xmlOutput); } }