private static void ExportAreaToXml(ref Xml.Area area)
 {
     area.Rooms = ReadAllRoomsInAreaDb(area.Id).
         Select(r => Mapper.Map<Xml.Room>(r)).ToArray();
     for (int i = 0; i < area.Rooms.Length; ++i)
         ExportRoomToXml(ref area.Rooms[i]);
 }
 private static void ExportActionToXml(ref Xml.Action action)
 {
     action.ActionResults = ReadAllActionResultsForActionDb(action.Id).
         Select(a => Mapper.Map<Xml.ActionResult>(a)).ToArray();
     action.ItemActionRequirements = ReadAllItemActionRequirementsForActionDb(action.Id).
         Select(i => Mapper.Map<Xml.ItemActionRequirement>(i)).ToArray();
     action.EventActionRequirements = ReadAllEventActionRequirementsForActionDb(action.Id).
         Select(e => Mapper.Map<Xml.EventActionRequirement>(e)).ToArray();
     action.CharacterActionRequirements = ReadAllCharacterActionRequirementsForActionDb(action.Id).
         Select(c => Mapper.Map<Xml.CharacterActionRequirement>(c)).ToArray();
 }
 private static void ImportParagraphFromXml(Xml.Paragraph paragraph, int roomId)
 {
     ImportParagraph(paragraph.Id, paragraph.Order, roomId);
     foreach (var paragraphRoomState in paragraph.ParagraphRoomStates)
         ImportParagraphRoomState(paragraphRoomState.Id, paragraphRoomState.RoomState, paragraph.Id);
     foreach (var paragraphState in paragraph.ParagraphStates)
         ImportParagraphStateFromXml(paragraphState, paragraph.Id);
 }
 private static void ImportNounFromXml(Xml.Noun noun, int paragraphStateId)
 {
     ImportNoun(noun.Id, noun.Text, paragraphStateId);
     foreach (var action in noun.Actions)
         ImportActionFromXml(action, noun.Id);
 }
 private static void ImportMessageFromXml(Xml.Message message)
 {
     ImportMessage(message.Id, message.Name, message.Text);
     foreach (var messageChoice in message.MessageChoices)
         ImportMessageChoiceFromXml(messageChoice, message.Id);
 }
 private static void ImportMessageChoiceFromXml(Xml.MessageChoice messageChoice, int messageId)
 {
     ImportMessageChoice(messageChoice.Id, messageChoice.Name, messageChoice.Text, messageId);
     foreach (var messageChoiceResult in messageChoice.MessageChoiceResults)
         ImportMessageChoiceResult(messageChoiceResult.Id, messageChoiceResult.Result, messageChoice.Id);
 }
 private static void ExportMessageToXml(ref Xml.Message message)
 {
     message.MessageChoices = ReadAllMessageChoicesForMessageDb(message.Id).
         Select(mc => Mapper.Map<Xml.MessageChoice>(mc)).ToArray();
     for (int i = 0; i < message.MessageChoices.Length; ++i)
         ExportMessageChoiceToXml(ref message.MessageChoices[i]);
 }
 private static void ImportRoomFromXml(Xml.Room room, int areaId)
 {
     ImportRoom(room.Id, room.Name, room.X, room.Y, room.Z, areaId);
     foreach(var roomState in room.RoomStates)
         ImportRoomState(roomState.Id, roomState.State, roomState.Time, roomState.Location, room.Id);
     foreach (var paragraph in room.Paragraphs)
         ImportParagraphFromXml(paragraph, room.Id);
 }
 private static void ImportActionFromXml(Xml.Action action, int nounId)
 {
     ImportAction(action.Id, action.VerbType, nounId);
     foreach (var actionResult in action.ActionResults)
         ImportActionResult(actionResult.Id, actionResult.Result, action.Id);
     foreach (var requirement in action.ItemActionRequirements)
         ImportItemActionRequirement(requirement.Id, requirement.Item, action.Id);
     foreach (var requirement in action.EventActionRequirements)
         ImportEventActionRequirement(requirement.Id, requirement.Event, action.Id);
     foreach (var requirement in action.CharacterActionRequirements)
         ImportCharacterActionRequirement(requirement.Id, requirement.Character, action.Id);
 }
 private static void ExportVerbTypeToXml(ref Xml.VerbType verbType)
 {
     verbType.Verbs = ReadAllVerbsForVerbTypeDb(verbType.Id).
         Select(v => Mapper.Map<Xml.Verb>(v)).ToArray();
 }
 private static void ExportRoomToXml(ref Xml.Room room)
 {
     room.Paragraphs = ReadAllParagraphsForRoomAndRoomStateDb(room.Id, null).
         Select(p => Mapper.Map<Xml.Paragraph>(p)).ToArray();
     for (int i = 0; i < room.Paragraphs.Length; ++i)
         ExportParagraphToXml(ref room.Paragraphs[i]);
     room.RoomStates = ReadAllRoomStatesForRoomDb(room.Id).
         Select(rs => Mapper.Map<Xml.RoomState>(rs)).ToArray();
 }
 private static void ExportResultTypeToXml(ref Xml.ResultType resultType)
 {
     resultType.ResultTypeJSONProperties = ReadAllResultTypeJSONPropertiesForResultTypeDb(resultType.Id).
         Select(rtjp => Mapper.Map<Xml.ResultTypeJSONProperty>(rtjp)).ToArray();
     resultType.Results = ReadAllResultsForResultTypeDb(resultType.Id).
         Select(r => Mapper.Map<Xml.Result>(r)).ToArray();
 }
 private static void ExportParagraphToXml(ref Xml.Paragraph paragraph)
 {
     paragraph.ParagraphRoomStates = ReadAllParagraphRoomStatesForParagraphDb(paragraph.Id).
         Select(prs => Mapper.Map<Xml.ParagraphRoomState>(prs)).ToArray();
     paragraph.ParagraphStates = ReadAllParagraphStatesForParagraphDb(paragraph.Id).
         Select(ps => Mapper.Map<Xml.ParagraphState>(ps)).ToArray();
     for (int i = 0; i < paragraph.ParagraphStates.Length; ++i)
         ExportParagraphStateToXml(ref paragraph.ParagraphStates[i]);
 }
 private static void ExportParagraphStateToXml(ref Xml.ParagraphState paragraphState)
 {
     paragraphState.Nouns = ReadAllNounsForParagraphStateDb(paragraphState.Id).
         Select(n => Mapper.Map<Xml.Noun>(n)).ToArray();
     for (int i = 0; i < paragraphState.Nouns.Length; ++i)
         ExportNounToXml(ref paragraphState.Nouns[i]);
 }
 private static void ExportNounToXml(ref Xml.Noun noun)
 {
     noun.Actions = ReadAllActionsForNounDb(noun.Id).
         Select(a => Mapper.Map<Xml.Action>(a)).ToArray();
     for(int i = 0; i < noun.Actions.Length; ++i)
         ExportActionToXml(ref noun.Actions[i]);
 }
 private static void ImportParagraphStateFromXml(Xml.ParagraphState paragraphState, int paragraphId)
 {
     ImportParagraphState(paragraphState.Id, paragraphState.State, paragraphState.Text, paragraphId);
     foreach (var noun in paragraphState.Nouns)
         ImportNounFromXml(noun, paragraphState.Id);
 }
 private static void ImportResultTypeFromXml(Xml.ResultType resultType)
 {
     ImportResultType(resultType.Id, resultType.Name);
     foreach (var resultTypeJSONProperty in resultType.ResultTypeJSONProperties)
         ImportResultTypeJSONProperty(resultTypeJSONProperty.Id, resultTypeJSONProperty.JSONProperty, resultTypeJSONProperty.DataType, resultType.Id);
     foreach (var result in resultType.Results)
         ImportResult(result.Id, result.Name, result.JSONData, resultType.Id);
 }
 private static void ImportAreaFromXml(Xml.Area area)
 {
     ImportArea(area.Id, area.Name, area.DisplayTime, area.Audio);
     foreach (var room in area.Rooms)
         ImportRoomFromXml(room, area.Id);
 }
 private static void ImportVerbTypeFromXml(Xml.VerbType verbType)
 {
     ImportVerbType(verbType.Id, verbType.Name);
     foreach (var verb in verbType.Verbs)
         ImportVerb(verb.Id, verb.Name, verbType.Id);
 }
 private static void ImportAudioFromXml(Xml.Audio audio)
 {
     ImportAudio(audio.Id, audio.Name, audio.AudioFile, audio.IsLooped);
 }
 private static void ImportGinTubFromXml(Xml.GinTub ginTub)
 {
     foreach (var item in ginTub.Items)
         ImportItem(item.Id, item.Name, item.Description);
     foreach (var evnt in ginTub.Events)
         ImportEvent(evnt.Id, evnt.Name, evnt.Description);
     foreach (var character in ginTub.Characters)
         ImportCharacter(character.Id, character.Name, character.Description);
     foreach (var jsonPropertyDataType in ginTub.JSONPropertyTypes)
         ImportJSONPropertyDataType(jsonPropertyDataType.Id, jsonPropertyDataType.DataType);
     foreach (var resultType in ginTub.ResultTypes)
         ImportResultTypeFromXml(resultType);
     foreach (var verbType in ginTub.VerbTypes)
         ImportVerbTypeFromXml(verbType);
     foreach (var location in ginTub.Locations)
         ImportLocation(location.Id, location.Name, location.LocationFile);
     foreach (var message in ginTub.Messages)
         ImportMessageFromXml(message);
     foreach (var area in ginTub.Areas)
         ImportAreaFromXml(area);
     foreach (var audio in ginTub.Audio)
         ImportAudioFromXml(audio);
     if(ginTub.GameStateOnInitialLoad != null)
         ImportGameStateOnInitialLoad(ginTub.GameStateOnInitialLoad.Area, ginTub.GameStateOnInitialLoad.Room, ginTub.GameStateOnInitialLoad.Time);
 }
 private static void ExportMessageChoiceToXml(ref Xml.MessageChoice messageChoice)
 {
     messageChoice.MessageChoiceResults = ReadAllMessageChoiceResultsForMessageChoiceDb(messageChoice.Id).
         Select(r => Mapper.Map<Xml.MessageChoiceResult>(r)).ToArray();
 }