private static Profile Load(IContentStorage storage, string profileFolder, Guid id, string file) { Profile profile = null; var path = storage.CombinePath(profileFolder, file); if (storage.IsFileExist(path)) { var document = new XmlDocument(); using (var stream = storage.OpenForRead(path)) { document.Load(stream); } var rootElement = document.DocumentElement; var name = rootElement.GetChildElementText(NameElementName) ?? file; var passwordHash = rootElement.GetChildElementText(PasswordHashElementName); profile = new Profile(id, name, passwordHash); profile.WorldName = rootElement.GetChildElementText(WorldElemenName); var activeData = rootElement.GetChildElementText(LastActiveElementName); DateTime lastActive; if (!string.IsNullOrEmpty(activeData) && DateTime.TryParse(activeData, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out lastActive)) { profile.LastActive = lastActive; } else { profile.LastActive = DateTime.MinValue; } } return(profile); }
private void LoadRoomsFromMapFolder( IContentStorage storage, string folder, IGameContext context, bool inDesign, object syncObject, IList <RoomData> dataToProcess) { var files = storage.GetFiles(folder); if ((files != null) && (files.Count > 0)) { Parallel.For( 0, files.Count, index => { var path = storage.CombinePath(folder, files[index]); LoadRoomsFromMapFile(storage, path, syncObject, context, inDesign, dataToProcess); }); } }
public static XmlElement LoadXml(this IContentStorage storage, string folder, string file) { var path = string.IsNullOrEmpty(folder) ? file : storage.CombinePath(folder, file); return(storage.LoadXml(path)); }