private static void DownloadScorecards(FileStore dataStore, Season season) { CrawlResults crawlResults = GetCrawlResultsForSeason(dataStore, season); if (crawlResults == null) { Log.WarnFormat("Season {0} has not been crawled yet.", season.Name); return; } Log.InfoFormat("Scorecard download started at {0} for season {1}", DateTime.Now.ToShortTimeString(), crawlResults.Season); var matchRecords = crawlResults.Classifications.SelectMany(m => m.Scorecards); Queue<Task> tasks = new Queue<Task>(); foreach (ScorecardDetails md in matchRecords) { if (md.ScorecardAvailable && !string.IsNullOrEmpty(md.ScorecardUrl)) { Log.InfoFormat("Downloading scorecard for {0}", md); tasks.Enqueue(DownloadScorecardAsync(md, dataStore)); } } Task.WaitAll(tasks.ToArray()); SaveCrawlerResults(crawlResults, dataStore); Log.InfoFormat("Scorecard download finished at {0} for season {1}", DateTime.Now.ToShortTimeString(), crawlResults.Season); }
private static void ParseScorecard(FileStore dataStore, ScorecardDetails md) { CricketMatch m = dataStore.Load<CricketMatch>(CricketMatch.GenerateId(md.Season, md.MatchCode)); if (m != null) { Log.InfoFormat("Match {0} ({1}) has already been imported", md.MatchCode, m); return; } Log.InfoFormat("Parsing scorecard for {0}", md); string scorecard = dataStore.LoadText(md.GenerateScorecardKey(), "html"); if (string.IsNullOrEmpty(scorecard)) return; DependencyFinder finder = new DependencyFinder(dataStore); ScorecardParser parser = new ScorecardParser(md, finder); parser.Parse(scorecard); CricketMatch match = parser.Match; dataStore.Save(match, match.Id); Log.Info(match.ToLongString()); }
public void Execute(FileStore dataStore) { foreach (Season season in GetSeasons(dataStore, StartSeason, EndSeason)) { ParseScorecards(dataStore, season); } }
public void Execute(FileStore dataStore) { foreach (Season season in GetSeasons(dataStore, StartSeason, EndSeason)) { RecheckSeason(dataStore, season); } }
public FileSettings(FileStore parent) { InitializeComponent(); this.parent = parent; settings = parent.SaveSettings.clone(); cmdFileApply.Enabled = false; checkBox1.Checked = settings.toSave[0]; checkBox2.Checked = settings.toSave[4]; checkBox3.Checked = settings.toSave[8]; checkBox4.Checked = settings.toSave[1]; checkBox5.Checked = settings.toSave[5]; checkBox6.Checked = settings.toSave[9]; checkBox7.Checked = settings.toSave[2]; checkBox8.Checked = settings.toSave[6]; checkBox9.Checked = settings.toSave[10]; checkBox10.Checked = settings.toSave[3]; checkBox11.Checked = settings.toSave[7]; textBox1.Text = settings.productTypeFolderPath; textBox2.Text = settings.ewkReportFolderPath; // ADD-START 08142007 EG blnTypeChanged = false; blnReportChanged = false; blnOptionChanged = false; // ADD-END 08142007 EG }
public void Execute(FileStore dataStore) { HtmlNode contentDiv = WebClient.GetWebContentNode(SEASONS_PAGE_URL); if (contentDiv == null) { Log.Error("Seasons page content not found!"); return; } var seasons = contentDiv.SelectNodes("table[1]//a") .Select(node => new Season { Name = node.InnerText.Replace('/', '-'), Url = node.GetAttributeValue("href", null) }) .Where(s => s.Name.CompareTo("1875") >= 0) .OrderBy(s => s.Name).ToList(); AllSeasons allSeasons = dataStore.Load<AllSeasons>(KEY); if (allSeasons == null) { allSeasons = new AllSeasons { Id = KEY, Seasons = seasons}; } else { allSeasons.Seasons = seasons; } dataStore.Save(allSeasons, KEY); }
public static void Reduce(List<BattingRecord> records, FileStore dataStore) { var grouped = from r in records where r.Team == "Somerset" group r by r.PlayerId into g select new BattingRecord { PlayerId = g.Key, Team = "Somerset", Matches = g.Sum(r => r.Matches), Innings = g.Sum(r => r.Innings), NotOut = g.Sum(r => r.NotOut), Highest = g.Max(r => r.Runs), Centuries = g.Where(r => r.Runs >= 100).Count(), Fifties = g.Where(r => r.Runs >= 50 && r.Runs < 100).Count(), Ducks = g.Where(r => r.NotOut == 0 && r.Runs == 0 && r.Innings == 1).Count(), Runs = g.Sum(r => r.Runs), Balls = g.Sum(r => r.Balls), Average = g.Sum(r => r.Runs) / (float)(g.Sum(r => r.Innings) - g.Sum(r => r.NotOut)) }; Console.WriteLine("Name M I NO Runs HS Ave 100 50 0"); foreach (var rec in grouped) { PlayerDetails player = dataStore.Load<PlayerDetails>(rec.PlayerId); Console.WriteLine("{0,-20} {1,2} {2,2} {3,2} {4,4} {5,3} {6,5:#0.00} {7,3} {8,2} {9,2}", player.KnownAs, rec.Matches, rec.Innings, rec.NotOut, rec.Runs, rec.Highest, rec.Average, rec.Centuries, rec.Fifties, rec.Ducks); } }
static void Main() { XmlConfigurator.Configure(); string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"Cricket\"); var store = new FileStore(path); bool exit = false; while (!exit) { Console.Write("Scorecards> "); string function = Console.ReadLine(); switch (function) { case "exit": case "x": exit = true; break; case "": break; default: CommandFactory.GetCommand(function).Execute(store); break; } Console.WriteLine(); } }
private void ReduceBatting(Season season, FileStore dataStore) { List<BattingRecord> records = dataStore.Load<List<BattingRecord>>(IndividualBattingMap.GenerateId(season.Name)); Batting.Reduce(records, dataStore); }
public void Setup() { if (File.Exists(_dbFileName)) File.Delete(_dbFileName); _store = new FileStore(Path.GetTempPath()); }
public void Execute(FileStore dataStore) { foreach (Season season in GetSeasons(dataStore, StartSeason, EndSeason)) { Log.InfoFormat("Running map functions for season {0}", season.Name); RunMapFunctions(dataStore, season); } }
public TranslationUnitItemStore() { _cursorStore = new CursorStore(this); _fileStore = new FileStore(); _locationStore = new SourceLocationStore(this); _sourceRangeStore = new SourceRangeStore(this); _typeStore = new TypeStore(this); }
public void Execute(FileStore dataStore) { foreach (Season season in GetSeasons(dataStore, StartSeason, EndSeason)) { Log.DebugFormat("Crawling Season {0} at {1}", season.Name, season.Url); CrawlResults results = RunCrawler(season); SaveCrawlerResults(results, dataStore); } }
public void ShouldRetrieveCurrentFeedBasedOnStoreId() { IStoreId id = new StoreId<string>("current.atom"); IStore store = new FileStore(FileSystemConfiguration); IRepresentation representation = store.GetCurrentFeed(id); Output output = Output.For(representation); Assert.AreEqual("http://restbucks.com/product-catalog/notifications/recent", GetSelfLinkValue(output.EntityBody)); }
public void Test() { var store = new FileStore(_rootPath); List<Task> tasks = new List<Task>(); HttpResponseMessage responseMessage = null; for (int i = 0; i < ConcurrencyLevel; i++) { var message = GetMessage(i % ConcurrencyLevel); var cacheKey = new CacheKey(message.RequestUri.ToString(), new string[0]); tasks.Add(new Task( () => store.AddOrUpdate(cacheKey, _responseBuilder.Send(message)))); tasks.Add(new Task( () => store.TryGetValue(cacheKey, out responseMessage))); tasks.Add(new Task( () => store.TryRemove(cacheKey))); } var randomisedList = new List<Task>(); //while (tasks.Count>0) //{ // var i = _random.Next(tasks.Count); // randomisedList.Add(tasks[i]); // tasks.RemoveAt(i); //} //tasks = randomisedList; foreach (var task in tasks) { task.ContinueWith(t => { if (t.IsFaulted) Assert.Fail(t.Exception.ToString()); }); task. Start(); } DateTime tt = DateTime.Now; var waited = Task.WaitAll(tasks.ToArray(), WaitTimeOut); // Console.WriteLine("Total milliseconds " + (DateTime.Now - tt).TotalMilliseconds); if(!waited) Assert.Fail("Timed out"); }
private static void RecheckSeason(FileStore dataStore, Season season) { CrawlResults existing = GetCrawlResultsForSeason(dataStore, season); if (existing == null) { Log.WarnFormat("Season {0} has not been crawled yet.", season.Name); return; } Spider spider = new Spider(); CrawlResults recheckResults = spider.Recheck(existing); Log.InfoFormat("\n{0}", DumpResults(recheckResults)); Log.InfoFormat("Crawler finished at {0}.", DateTime.Now.ToShortTimeString()); SaveCrawlerResults(recheckResults, dataStore); }
private static void SaveScorecard(ScorecardDetails details, Task<string> task, FileStore dataStore) { if (task.Exception != null) { Log.Error(string.Format("Failed to download file from http://www.cricketarchive.com{0}", details.ScorecardUrl), task.Exception); return; } string scorecard = task.Result; if (string.IsNullOrEmpty(scorecard)) { Log.WarnFormat("Nothing returned from http://www.cricketarchive.com{0}", details.ScorecardUrl); return; } dataStore.StoreText(scorecard, details.GenerateScorecardKey(), "html"); }
private static void ParseScorecards(FileStore dataStore, Season season) { CrawlResults crawlResults = GetCrawlResultsForSeason(dataStore, season); if (crawlResults == null) { Log.WarnFormat("Season {0} has not been crawled yet.", season.Name); return; } Log.InfoFormat("Scorecard parsing started at {0} for season {1}", DateTime.Now.ToShortTimeString(), crawlResults.Season); var matchRecords = crawlResults.Classifications.SelectMany(m => m.Scorecards); foreach (ScorecardDetails md in matchRecords) { ParseScorecard(dataStore, md); } Log.InfoFormat("Scorecard parsing finished at {0} for season {1}", DateTime.Now.ToShortTimeString(), season.Name); }
/// <summary> /// Import a beamap into our local <see cref="FileStore"/> storage. /// If the beatmap is already imported, the existing instance will be returned. /// </summary> /// <param name="reader">The beatmap archive to be read.</param> /// <returns>The imported beatmap, or an existing instance if it is already present.</returns> private BeatmapSetInfo importToStorage(FileStore files, BeatmapStore beatmaps, ArchiveReader reader) { // let's make sure there are actually .osu files to import. string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); if (string.IsNullOrEmpty(mapName)) { throw new InvalidOperationException("No beatmap files found in the map folder."); } // for now, concatenate all .osu files in the set to create a unique hash. MemoryStream hashable = new MemoryStream(); foreach (string file in reader.Filenames.Where(f => f.EndsWith(".osu"))) { using (Stream s = reader.GetStream(file)) s.CopyTo(hashable); } var hash = hashable.ComputeSHA2Hash(); // check if this beatmap has already been imported and exit early if so. var beatmapSet = beatmaps.BeatmapSets.FirstOrDefault(b => b.Hash == hash); if (beatmapSet != null) { undelete(beatmaps, files, beatmapSet); // ensure all files are present and accessible foreach (var f in beatmapSet.Files) { if (!storage.Exists(f.FileInfo.StoragePath)) { using (Stream s = reader.GetStream(f.Filename)) files.Add(s, false); } } // todo: delete any files which shouldn't exist any more. return(beatmapSet); } List <BeatmapSetFileInfo> fileInfos = new List <BeatmapSetFileInfo>(); // import files to manager foreach (string file in reader.Filenames) { using (Stream s = reader.GetStream(file)) fileInfos.Add(new BeatmapSetFileInfo { Filename = file, FileInfo = files.Add(s) }); } BeatmapMetadata metadata; using (var stream = new StreamReader(reader.GetStream(mapName))) metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata; beatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = metadata.OnlineBeatmapSetID, Beatmaps = new List <BeatmapInfo>(), Hash = hash, Files = fileInfos, Metadata = metadata }; var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu")); foreach (var name in mapNames) { using (var raw = reader.GetStream(name)) using (var ms = new MemoryStream()) //we need a memory stream so we can seek and shit using (var sr = new StreamReader(ms)) { raw.CopyTo(ms); ms.Position = 0; var decoder = BeatmapDecoder.GetDecoder(sr); Beatmap beatmap = decoder.Decode(sr); beatmap.BeatmapInfo.Path = name; beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash(); beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash(); // TODO: Diff beatmap metadata with set metadata and leave it here if necessary beatmap.BeatmapInfo.Metadata = null; RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID); // TODO: this should be done in a better place once we actually need to dynamically update it. beatmap.BeatmapInfo.Ruleset = ruleset; beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance()?.CreateDifficultyCalculator(beatmap).Calculate() ?? 0; beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo); } } return(beatmapSet); }
protected virtual async Task <UIImage> GetImageAsync(string sourcePath, ImageSource source) { if (CancellationToken.IsCancellationRequested) { return(null); } byte[] bytes = null; string path = sourcePath; try { switch (source) { case ImageSource.ApplicationBundle: case ImageSource.Filepath: if (FileStore.Exists(path)) { bytes = await FileStore.ReadBytesAsync(path).ConfigureAwait(false); } break; case ImageSource.Url: var downloadedData = await DownloadCache.GetAsync(path, Parameters.CacheDuration).ConfigureAwait(false); bytes = downloadedData.Bytes; path = downloadedData.CachedPath; break; } } catch (Exception ex) { Logger.Error("Unable to retrieve image data", ex); Parameters.OnError(ex); return(null); } if (bytes == null) { return(null); } return(await Task.Run(() => { if (CancellationToken.IsCancellationRequested) { return null; } // Special case to handle WebP decoding on iOS if (sourcePath.ToLowerInvariant().EndsWith(".webp", StringComparison.InvariantCulture)) { return new WebP.Touch.WebPCodec().Decode(bytes); } nfloat scale = _imageScale >= 1 ? _imageScale : _screenScale; var image = new UIImage(NSData.FromArray(bytes), scale); if (Parameters.Transformations != null && Parameters.Transformations.Count > 0) { foreach (var transformation in Parameters.Transformations) { try { var bitmapHolder = transformation.Transform(new BitmapHolder(image)); image = bitmapHolder.ToNative(); } catch (Exception ex) { Logger.Error("Can't apply transformation " + transformation.Key + " to image " + path, ex); } } } return image; }).ConfigureAwait(false)); }
partial void FileStores_Inserting(FileStore entity) { entity.FileMetaData.FileSize = ConvertBytesToMegabytes(entity.FileBinaryContent.LongCount()).ToString("0.00") + " MB"; }
protected void ValidateFile(BaseController baseController, HttpPostedFileBase file, FileStore fileStore, int maxContentLengthMB, string previousFileName = null, string[] allowedExtensions = null) { if (!baseController.ModelState.IsValid) return; if (file == null) { baseController.ModelState.AddModelError(BaseCache.FileField, String.Format(ValidationResource.Global_Required_ErrorMessage, FieldResource.Global_ImportFile_Name)); return; } string fixedFileName = Path.GetFileName(file.FileName) ?? "___error.nfo"; if (allowedExtensions != null && allowedExtensions.Length > 0) { string fileExtension = Path.GetExtension(fixedFileName); if (allowedExtensions.All(ae => !ae.Equals(fileExtension, StringComparison.InvariantCultureIgnoreCase))) { baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_IncorrectFileFormat_ErrorMessage); return; } } if (fixedFileName.Length > 100) { baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_BadFileName_ErrorMessage); return; } if (file.ContentLength == 0) { baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_FileIsEmpty_ErrorMessage); return; } if (file.ContentLength > 1024 * 1024 * (long)maxContentLengthMB) { baseController.ModelState.AddModelError(BaseCache.FileField, String.Format(ValidationResource.Global_FileIsTooLarge_ErrorMessage, maxContentLengthMB)); return; } if (fileStore == FileStore.None) return; if (file.ContentLength > FolderRemainMB * (long)1048576) { baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_StoreIsFull_ErrorMessage); return; } string absoluteFolderPath; string relativeFolderPath; int folderQuota; GetFolderPath(baseController.Server, fileStore, out absoluteFolderPath, out relativeFolderPath, out folderQuota); string absolutePreviousFilePath = String.IsNullOrEmpty(previousFileName) ? null : Path.Combine(absoluteFolderPath, previousFileName); string absoluteFilePath = Path.Combine(absoluteFolderPath, fixedFileName); if (File.Exists(absoluteFilePath) && !absoluteFilePath.Equals(absolutePreviousFilePath, StringComparison.InvariantCultureIgnoreCase)) { baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_FileExists_ErrorMessage); return; } if (!String.IsNullOrEmpty(absolutePreviousFilePath) && File.Exists(absolutePreviousFilePath)) { File.Delete(absolutePreviousFilePath); } try { file.SaveAs(absoluteFilePath); RelativeFilePath = Path.Combine(relativeFolderPath, fixedFileName); var converter = new Converter(baseController.Server); VideoFile videoFile = converter.GetVideoInfo(absoluteFilePath); VideoDuration = Convert.ToInt32(videoFile.Duration.TotalSeconds); } catch (Exception e) { try { if (File.Exists(absoluteFilePath)) { File.Delete(absoluteFilePath); } } catch (Exception ex) { Logger.SetLog(ex); } Logger.SetLog(e); baseController.ModelState.AddModelError(BaseCache.FileField, ValidationResource.Global_FileCannotBeSaved_ErrorMessage); } }
/// <summary> /// This thread function measures vault latency every /// VAULT_MEASUREMENT_INTERVAL milliseconds. /// /// Note that, because this function does not execute from a script /// context, it cannot call script functions. Instead, a companion /// DelayCommand continuation on the main server thread will check the /// current latency value and save it as appropriate. /// </summary> private static void VaultPingThreadRoutine() { string VaultPingFile = String.Format( "{0}Server{1}.txt", SystemInfo.GetCentralVaultPath(), LocalServerId); for (; ;) { // // Open the ping file on the vault. If we fail to open it then // something has gone wrong with the vault connection. // try { string ConnectionString = FileStoreProvider.DefaultVaultConnectionString; uint Tick = (uint)Environment.TickCount; using (StreamWriter PingFile = File.CreateText(VaultPingFile)) { PingFile.WriteLine( "Server {0} is up at {1}.", LocalServerId, DateTime.UtcNow); } if (!String.IsNullOrEmpty(ConnectionString)) { FileStore Store = FileStoreProvider.CreateAzureFileStore(ConnectionString); FileStoreContainer StoreContainer = Store.GetContainerReference(FileStoreNamespace.ServerVault); FileStoreFile StoreFile = StoreContainer.GetFileReference(String.Format("Server{0}.txt", LocalServerId)); using (MemoryStream MemStream = new MemoryStream()) { StoreFile.Write(MemStream); } } Tick = (uint)Environment.TickCount - Tick; // // Report the response time. // lock (CurrentLatencyLock) { CurrentVaultLatency = (int)Tick; } } catch (Exception e) { Logger.Log("LatencyMonitor.VaultPingThreadRoutine: Exception pinging server vault: {0}", e); // // Report a response time of -1 to indicate that no // measurement could be taken. // lock (CurrentLatencyLock) { CurrentVaultLatency = (int)-1; } } Thread.Sleep(VAULT_MEASUREMENT_INTERVAL); } }
private void load() { try { using (var str = File.OpenRead(typeof(OsuGameBase).Assembly.Location)) VersionHash = str.ComputeMD5Hash(); } catch { // special case for android builds, which can't read DLLs from a packed apk. // should eventually be handled in a better way. VersionHash = $"{Version}-{RuntimeInfo.OS}".ComputeMD5Hash(); } Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage)); dependencies.CacheAs(Storage); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(largeStore); dependencies.CacheAs(this); dependencies.CacheAs(LocalConfig); AddFont(Resources, @"Fonts/osuFont"); AddFont(Resources, @"Fonts/Torus-Regular"); AddFont(Resources, @"Fonts/Torus-Light"); AddFont(Resources, @"Fonts/Torus-SemiBold"); AddFont(Resources, @"Fonts/Torus-Bold"); AddFont(Resources, @"Fonts/Noto-Basic"); AddFont(Resources, @"Fonts/Noto-Hangul"); AddFont(Resources, @"Fonts/Noto-CJK-Basic"); AddFont(Resources, @"Fonts/Noto-CJK-Compatibility"); AddFont(Resources, @"Fonts/Noto-Thai"); AddFont(Resources, @"Fonts/Venera-Light"); AddFont(Resources, @"Fonts/Venera-Bold"); AddFont(Resources, @"Fonts/Venera-Black"); Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY; runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore <byte[]>(Resources, "Skins/Legacy"))); dependencies.CacheAs <ISkinSource>(SkinManager); // needs to be done here rather than inside SkinManager to ensure thread safety of CurrentSkinInfo. SkinManager.ItemRemoved.BindValueChanged(weakRemovedInfo => { if (weakRemovedInfo.NewValue.TryGetTarget(out var removedInfo)) { Schedule(() => { // check the removed skin is not the current user choice. if it is, switch back to default. if (removedInfo.ID == SkinManager.CurrentSkinInfo.Value.ID) { SkinManager.CurrentSkinInfo.Value = SkinInfo.Default; } }); } }); EndpointConfiguration endpoints = UseDevelopmentServer ? (EndpointConfiguration) new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration(); dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints)); dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient(endpoints)); dependencies.CacheAs(multiplayerClient = new MultiplayerClient(endpoints)); var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage)); dependencies.Cache(FileStore = new FileStore(contextFactory, Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Host, () => DifficultyCache, LocalConfig)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap, true)); // this should likely be moved to ArchiveModelManager when another case appers where it is necessary // to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to // allow lookups to be done on the child (ScoreManager in this case) to perform the cascading delete. List <ScoreInfo> getBeatmapScores(BeatmapSetInfo set) { var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList(); return(ScoreManager.QueryScores(s => beatmapIds.Contains(s.Beatmap.ID)).ToList()); } BeatmapManager.ItemRemoved.BindValueChanged(i => { if (i.NewValue.TryGetTarget(out var item)) { ScoreManager.Delete(getBeatmapScores(item), true); } }); BeatmapManager.ItemUpdated.BindValueChanged(i => { if (i.NewValue.TryGetTarget(out var item)) { ScoreManager.Undelete(getBeatmapScores(item), true); } }); dependencies.Cache(DifficultyCache = new BeatmapDifficultyCache()); AddInternal(DifficultyCache); dependencies.Cache(UserCache = new UserLookupCache()); AddInternal(UserCache); var scorePerformanceManager = new ScorePerformanceCache(); dependencies.Cache(scorePerformanceManager); AddInternal(scorePerformanceManager); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(new SessionStatics()); dependencies.Cache(new OsuColour()); RegisterImportHandler(BeatmapManager); RegisterImportHandler(ScoreManager); RegisterImportHandler(SkinManager); // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); dependencies.CacheAs <IBindable <WorkingBeatmap> >(Beatmap); dependencies.CacheAs(Beatmap); FileStore.Cleanup(); // add api components to hierarchy. if (API is APIAccess apiAccess) { AddInternal(apiAccess); } AddInternal(spectatorStreaming); AddInternal(multiplayerClient); AddInternal(RulesetConfigCache); MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; GlobalActionContainer globalBindings; MenuCursorContainer.Child = globalBindings = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; base.Content.Add(CreateScalingContainer().WithChild(MenuCursorContainer)); KeyBindingStore.Register(globalBindings); dependencies.Cache(globalBindings); PreviewTrackManager previewTrackManager; dependencies.Cache(previewTrackManager = new PreviewTrackManager()); Add(previewTrackManager); AddInternal(MusicController = new MusicController()); dependencies.CacheAs(MusicController); Ruleset.BindValueChanged(onRulesetChanged); }
public static void Save(FileStore store, PlayerDetails player) { store.Save(player, player.Id); }
protected async override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var requestUri = request.RequestUri.ToString(); var requestPath = request.RequestUri.PathAndQuery; var proxyRequestHost = Context.HttpContext.Request.Host; var proxyAddress = $"{Context.HttpContext.Request.Scheme}://{proxyRequestHost}"; var siteSettings = SiteSettings.Current; var sourceAddress = siteSettings.SourceAddress; // Reroute access token requests if (IsAccessTokenRequest(requestPath)) { return(new HttpResponseMessage { Content = new StringContent(await HttpContext.GetTokenAsync("access_token")) }); } if (IsIdTokenRequest(requestPath)) { return(new HttpResponseMessage { Content = new StringContent(await HttpContext.GetTokenAsync("id_token")) }); } // Reroute logout if (IsLogoutRequest(requestPath)) { return(Redirect($"{proxyAddress}/account/logout?returnUrl={WebUtility.UrlEncode(request.Headers.Referrer.ToString() ?? "/")}")); } // Reroute login request to target url (sometimes users are redirected to login if the auth cookie has only just been set) if (IsLoginRequest(requestPath)) { var redirectUri = GetQueryParameter(request.RequestUri.Query, "redirect_to"); if (!string.IsNullOrEmpty(redirectUri)) { return(Redirect(WebUtility.UrlDecode(redirectUri))); } } // Redirect to previously selected language if (IsRootUrl(requestPath) && siteSettings.AutoLanguageRedirect && !(request.Headers.Referrer?.ToString() ?? "").StartsWith(proxyAddress)) { var requestLanguageCookie = GetRequestLanguageCookie(request); if (!string.IsNullOrEmpty(requestLanguageCookie) && requestLanguageCookie != siteSettings.DefaultLanguage) { return(Redirect($"{proxyAddress}/{requestLanguageCookie}")); } } // Modify request headers (for authentication) var wpUserId = await UserService.MapToWpUserAsync(HttpContext.User); request.Headers.Add("X-Wp-Proxy-User-Id", wpUserId.ToString()); request.Headers.Add("X-Wp-Proxy-Key", Settings.ProxyKey); request.Headers.Host = siteSettings.SourceHost; // Determine if content can/should be cached var isDynamicContent = !IsStaticContent(requestUri); var canCache = CanCacheRequest(request) || !isDynamicContent; var isScript = IsScript(requestUri); // Determine cache key var requestKey = canCache ? (request.RequestUri.ToString() + "|" + (isDynamicContent ? wpUserId: 0)) : null; var cacheKey = canCache ? ComputeCacheKeyHash(requestKey) : null; // Load from cache if (canCache) { var responseCacheItem = await Cache.GetAsync <ResponseCacheItem>(cacheKey, refreshOnWPUpdate : isDynamicContent || isScript); if (responseCacheItem != null) { var cachedResponse = await responseCacheItem.ToResponseMessage(FileStore); if (canCache) { SetLanguageCookies(cachedResponse, request, siteSettings.DefaultLanguage); } return(cachedResponse); } } // Execute request if (canCache) { // Remove cookie headers request.Headers.Remove("cookie"); } var response = await base.SendAsync(request, cancellationToken); if (canCache) { // Remove cookie headers response.Headers.Remove("cookie"); response.Headers.Remove("set-cookie"); } if (response.StatusCode == HttpStatusCode.Unauthorized) { return(RedirectToLogin()); } // Handle depending on media type var mediaType = response.Content?.Headers?.ContentType?.MediaType ?? ""; if (IsTextMediaType(mediaType)) { // Text content (documents, json responses etc.) may contain references to // the destination/source address and the content may need to be transformed to // replace these references with the proxy's address // Read content and transform content (replace source address with proxy address) var contentBuilder = new StringBuilder(await response.Content.ReadAsStringAsync()); RewriteUrls(contentBuilder, sourceAddress, proxyAddress); var contentString = contentBuilder.ToString(); response.Content = new StringContent(contentString, Encoding.UTF8, response.Content.Headers.ContentType.MediaType); // Cache content if response is valid for caching if (canCache && ShouldCacheResponse(response)) { // Cache Item (if not already cached) await Cache.GetOrCreateAsync(cacheKey, () => Task.FromResult(ResponseCacheItem.ForTextContent(response, contentString)), refreshOnWPUpdate : true); } } else if (IsMultimediaMediaType(mediaType)) { // Check if response should be cached (e.g not a 500 response or similar) if (canCache && ShouldCacheResponse(response)) { // Read content stream to memory var contentHeaders = response.Content.Headers; var content = await response.Content.ReadAsStreamAsync(); var ms = new MemoryStream(); await content.CopyToAsync(ms); // Save memory stream to disk/storage cache ms.Position = 0; var storageKey = $"{siteSettings.SourceHost}/{cacheKey}"; await FileStore.WriteFileAsync(storageKey, ms); // Create cache entry which references disk/storage await Cache.GetOrCreateAsync(cacheKey, () => Task.FromResult( ResponseCacheItem.ForStreamContent(response, storageKey)), TimeSpan.FromMinutes(15), refreshOnWPUpdate : isDynamicContent ); // Link response to memory stream ms.Position = 0; response.Content = new StreamContent(ms); foreach (var header in contentHeaders) { response.Content.Headers.Add(header.Key, header.Value); } } } RewriteRedirectUrls(response, request, sourceAddress, proxyAddress); if (canCache && isDynamicContent) { SetLanguageCookies(response, request, siteSettings.DefaultLanguage); } return(response); }
public void InjectedStorageIsResolved() { var config = new EngineConfiguration() .WithRandomLocation(); var expected = new FileStore(config); config.SetStoreFactory((c) => expected); var actual = config.CreateStore(); Assert.AreSame(expected, actual); Directory.Delete(config.Location.OfJournal, true); }
private void load() { try { using (var str = File.OpenRead(typeof(OsuGameBase).Assembly.Location)) VersionHash = str.ComputeMD5Hash(); } catch { // special case for android builds, which can't read DLLs from a packed apk. // should eventually be handled in a better way. VersionHash = $"{Version}-{RuntimeInfo.OS}".ComputeMD5Hash(); } Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage)); dependencies.Cache(realmFactory = new RealmContextFactory(Storage, "client")); dependencies.CacheAs(Storage); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(largeStore); dependencies.CacheAs(this); dependencies.CacheAs(LocalConfig); InitialiseFonts(); Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY; runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Resources, Audio)); dependencies.CacheAs <ISkinSource>(SkinManager); // needs to be done here rather than inside SkinManager to ensure thread safety of CurrentSkinInfo. SkinManager.ItemRemoved.BindValueChanged(weakRemovedInfo => { if (weakRemovedInfo.NewValue.TryGetTarget(out var removedInfo)) { Schedule(() => { // check the removed skin is not the current user choice. if it is, switch back to default. if (removedInfo.ID == SkinManager.CurrentSkinInfo.Value.ID) { SkinManager.CurrentSkinInfo.Value = SkinInfo.Default; } }); } }); EndpointConfiguration endpoints = UseDevelopmentServer ? (EndpointConfiguration) new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration(); MessageFormatter.WebsiteRootUrl = endpoints.WebsiteRootUrl; dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints, VersionHash)); dependencies.CacheAs(spectatorClient = new OnlineSpectatorClient(endpoints)); dependencies.CacheAs(multiplayerClient = new OnlineMultiplayerClient(endpoints)); var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage)); dependencies.Cache(fileStore = new FileStore(contextFactory, Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Scheduler, Host, () => difficultyCache, LocalConfig)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap, performOnlineLookups: true)); // this should likely be moved to ArchiveModelManager when another case appears where it is necessary // to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to // allow lookups to be done on the child (ScoreManager in this case) to perform the cascading delete. List <ScoreInfo> getBeatmapScores(BeatmapSetInfo set) { var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList(); return(ScoreManager.QueryScores(s => beatmapIds.Contains(s.BeatmapInfo.ID)).ToList()); } BeatmapManager.ItemRemoved.BindValueChanged(i => { if (i.NewValue.TryGetTarget(out var item)) { ScoreManager.Delete(getBeatmapScores(item), true); } }); BeatmapManager.ItemUpdated.BindValueChanged(i => { if (i.NewValue.TryGetTarget(out var item)) { ScoreManager.Undelete(getBeatmapScores(item), true); } }); dependencies.Cache(difficultyCache = new BeatmapDifficultyCache()); AddInternal(difficultyCache); dependencies.Cache(userCache = new UserLookupCache()); AddInternal(userCache); var scorePerformanceManager = new ScorePerformanceCache(); dependencies.Cache(scorePerformanceManager); AddInternal(scorePerformanceManager); migrateDataToRealm(); dependencies.Cache(rulesetConfigCache = new RulesetConfigCache(realmFactory, RulesetStore)); var powerStatus = CreateBatteryInfo(); if (powerStatus != null) { dependencies.CacheAs(powerStatus); } dependencies.Cache(SessionStatics = new SessionStatics()); dependencies.Cache(new OsuColour()); RegisterImportHandler(BeatmapManager); RegisterImportHandler(ScoreManager); RegisterImportHandler(SkinManager); // drop track volume game-wide to leave some head-room for UI effects / samples. // this means that for the time being, gameplay sample playback is louder relative to the audio track, compared to stable. // we may want to revisit this if users notice or complain about the difference (consider this a bit of a trial). Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, globalTrackVolumeAdjust); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); dependencies.CacheAs <IBindable <WorkingBeatmap> >(Beatmap); dependencies.CacheAs(Beatmap); fileStore.Cleanup(); // add api components to hierarchy. if (API is APIAccess apiAccess) { AddInternal(apiAccess); } AddInternal(spectatorClient); AddInternal(multiplayerClient); AddInternal(rulesetConfigCache); GlobalActionContainer globalBindings; var mainContent = new Drawable[] { MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }, // to avoid positional input being blocked by children, ensure the GlobalActionContainer is above everything. globalBindings = new GlobalActionContainer(this) }; MenuCursorContainer.Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }; base.Content.Add(CreateScalingContainer().WithChildren(mainContent)); KeyBindingStore = new RealmKeyBindingStore(realmFactory); KeyBindingStore.Register(globalBindings, RulesetStore.AvailableRulesets); dependencies.Cache(globalBindings); PreviewTrackManager previewTrackManager; dependencies.Cache(previewTrackManager = new PreviewTrackManager()); Add(previewTrackManager); AddInternal(MusicController = new MusicController()); dependencies.CacheAs(MusicController); Ruleset.BindValueChanged(onRulesetChanged); }
private void load() { dependencies.Cache(this); dependencies.Cache(LocalConfig); connection = createConnection(); connection.CreateTable <StoreVersion>(); dependencies.Cache(API = new APIAccess { Username = LocalConfig.Get <string>(OsuSetting.Username), Token = LocalConfig.Get <string>(OsuSetting.Token) }); dependencies.Cache(RulesetStore = new RulesetStore(connection)); dependencies.Cache(FileStore = new FileStore(connection, Host.Storage)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, API, Host)); dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(connection, RulesetStore)); dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); BeatmapManager.DefaultBeatmap = defaultBeatmap; Beatmap.ValueChanged += b => { var trackLoaded = lastBeatmap?.TrackLoaded ?? false; // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (!trackLoaded || lastBeatmap?.Track != b.Track) { if (trackLoaded) { Debug.Assert(lastBeatmap != null); Debug.Assert(lastBeatmap.Track != null); lastBeatmap.DisposeTrack(); } Audio.Track.AddItem(b.Track); } lastBeatmap = b; }; API.Register(this); }
public FileStoreFixture() { string postfix = Guid.NewGuid().ToString(); Path = System.IO.Path.Combine( System.IO.Path.GetTempPath(), $"filestore_test_{postfix}"); Store = new FileStore(Path); StoreNamespace = Guid.NewGuid().ToString(); Store.InitNamespace(StoreNamespace); Address1 = new Address(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, }); Address2 = new Address(new byte[] { 0x55, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xdd, }); TxId1 = new TxId(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xcc, }); TxId2 = new TxId(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xdd, }); TxId3 = new TxId(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xee, }); Hash1 = new HashDigest <SHA256>(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xcc, }); Hash2 = new HashDigest <SHA256>(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xdd, }); Hash3 = new HashDigest <SHA256>(new byte[] { 0x45, 0xa2, 0x21, 0x87, 0xe2, 0xd8, 0x85, 0x0b, 0xb3, 0x57, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x88, 0x69, 0x58, 0xbc, 0x3e, 0x85, 0x60, 0x92, 0x9c, 0xcc, 0x9c, 0xee, }); Block1 = TestUtils.MineGenesis <BaseAction>(); Block2 = TestUtils.MineNext(Block1); Block3 = TestUtils.MineNext(Block2); Transaction1 = MakeTransaction(); Transaction2 = MakeTransaction(); }
public DependencyFinder(FileStore dataStore) { _dataStore = dataStore; }
public void Execute(FileStore dataStore) { throw new NotImplementedException(); }
private void load() { Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage)); var largeStore = new LargeTextureStore(new TextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); largeStore.AddStore(new TextureLoaderStore(new OnlineStore())); dependencies.Cache(largeStore); dependencies.CacheAs(this); dependencies.Cache(LocalConfig); //this completely overrides the framework default. will need to change once we make a proper FontStore. dependencies.Cache(Fonts = new FontStore(new GlyphStore(Resources, @"Fonts/FontAwesome"))); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio)); dependencies.CacheAs <ISkinSource>(SkinManager); API = new APIAccess(LocalConfig); dependencies.Cache(API); dependencies.CacheAs <IAPIProvider>(API); var defaultBeatmap = new DummyWorkingBeatmap(this); beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap)); dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, BeatmapManager, Host.Storage, contextFactory, Host)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(new OsuColour()); fileImporters.Add(BeatmapManager); fileImporters.Add(ScoreManager); fileImporters.Add(SkinManager); // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); dependencies.CacheAs <BindableBeatmap>(beatmap); dependencies.CacheAs <IBindableBeatmap>(beatmap); FileStore.Cleanup(); AddInternal(API); GlobalActionContainer globalBinding; MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; MenuCursorContainer.Child = globalBinding = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; base.Content.Add(new DrawSizePreservingFillContainer { Child = MenuCursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); PreviewTrackManager previewTrackManager; dependencies.Cache(previewTrackManager = new PreviewTrackManager()); Add(previewTrackManager); }
public ProgramArguments(Options options) { GetInputData = new FileInputData(options.Input); GetDataStore = new FileStore(options.Input); }
public static PlayerDetails Load(FileStore store, string id) { return store.Load<PlayerDetails>(id); }
public DependencyFinder(FileStore dataStore) { _dataStore = dataStore; }
public void Save() { if (!StringUtility.IsNullOrEmpty(this.StorageRoot)) { try { using (var fileStream = new FileStream(this._filePath, FileMode.Create)) { if (this != null) { lock (this._bindingSync) { FileStore store = new FileStore(); foreach (BindingLease lease in this._assignedTable.Values) { FileStore item = new FileStore(); item.ClientId = lease.ClientId; item.Owner = lease.Owner.ToArray(); item.Address = lease.Address.ToArray(); item.HostName = lease.HostName; item.Expiration = lease.Expiration; item.SessionId = lease.SessionId; item.State = lease.State; store.Add(item); } byte[] serializedData = Reflection.Serialize(store, typeof(FileStore)); fileStream.Write(serializedData, 0, serializedData.Length); fileStream.Close(); } } } } catch (Exception ex) { Logger.WriteError(this, "Error Message:" + ex.Message.ToString(), ex); } } }
private void load() { Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage)); dependencies.CacheAs(Storage); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(largeStore); dependencies.CacheAs(this); dependencies.Cache(LocalConfig); AddFont(Resources, @"Fonts/osuFont"); AddFont(Resources, @"Fonts/Torus-Regular"); AddFont(Resources, @"Fonts/Torus-Light"); AddFont(Resources, @"Fonts/Torus-SemiBold"); AddFont(Resources, @"Fonts/Torus-Bold"); AddFont(Resources, @"Fonts/Noto-Basic"); AddFont(Resources, @"Fonts/Noto-Hangul"); AddFont(Resources, @"Fonts/Noto-CJK-Basic"); AddFont(Resources, @"Fonts/Noto-CJK-Compatibility"); AddFont(Resources, @"Fonts/Venera-Light"); AddFont(Resources, @"Fonts/Venera-Bold"); AddFont(Resources, @"Fonts/Venera-Black"); Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY; runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore <byte[]>(Resources, "Skins/Legacy"))); dependencies.CacheAs <ISkinSource>(SkinManager); if (API == null) { API = new APIAccess(LocalConfig); } dependencies.CacheAs(API); var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory, Storage)); dependencies.Cache(FileStore = new FileStore(contextFactory, Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap)); // this should likely be moved to ArchiveModelManager when another case appers where it is necessary // to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to // allow lookups to be done on the child (ScoreManager in this case) to perform the cascading delete. List <ScoreInfo> getBeatmapScores(BeatmapSetInfo set) { var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList(); return(ScoreManager.QueryScores(s => beatmapIds.Contains(s.Beatmap.ID)).ToList()); } BeatmapManager.ItemRemoved += i => ScoreManager.Delete(getBeatmapScores(i), true); BeatmapManager.ItemAdded += i => ScoreManager.Undelete(getBeatmapScores(i), true); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(new SessionStatics()); dependencies.Cache(new OsuColour()); fileImporters.Add(BeatmapManager); fileImporters.Add(ScoreManager); fileImporters.Add(SkinManager); // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); // ScheduleAfterChildren is safety against something in the current frame accessing the previous beatmap's track // and potentially causing a reload of it after just unloading. // Note that the reason for this being added *has* been resolved, so it may be feasible to removed this if required. Beatmap.BindValueChanged(b => ScheduleAfterChildren(() => { // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (b.OldValue?.TrackLoaded == true && b.OldValue?.Track != b.NewValue?.Track) { b.OldValue.RecycleTrack(); } })); dependencies.CacheAs <IBindable <WorkingBeatmap> >(Beatmap); dependencies.CacheAs(Beatmap); FileStore.Cleanup(); if (API is APIAccess apiAcces) { AddInternal(apiAcces); } AddInternal(RulesetConfigCache); GlobalActionContainer globalBinding; MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; MenuCursorContainer.Child = globalBinding = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; base.Content.Add(CreateScalingContainer().WithChild(MenuCursorContainer)); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); PreviewTrackManager previewTrackManager; dependencies.Cache(previewTrackManager = new PreviewTrackManager()); Add(previewTrackManager); Ruleset.BindValueChanged(onRulesetChanged); }
private void load(FileStore store, GameHost host) { this.host = host; this.store = store; }
public virtual async Task <Tuple <Stream, LoadingResult, ImageInformation> > Resolve(string identifier, TaskParameter parameters, CancellationToken token) { NSBundle bundle = null; var filename = Path.GetFileNameWithoutExtension(identifier); var tmpPath = Path.GetDirectoryName(identifier).Trim('/'); var filenamePath = string.IsNullOrWhiteSpace(tmpPath) ? null : tmpPath + "/"; foreach (var fileType in fileTypes) { string file = null; var extension = Path.HasExtension(identifier) ? Path.GetExtension(identifier) : string.IsNullOrWhiteSpace(fileType) ? string.Empty : "." + fileType; token.ThrowIfCancellationRequested(); int scale = (int)ScaleHelper.Scale; if (scale > 1) { while (scale > 1) { token.ThrowIfCancellationRequested(); var tmpFile = string.Format("{0}@{1}x{2}", filename, scale, extension); bundle = NSBundle._AllBundles.FirstOrDefault(bu => { var path = string.IsNullOrWhiteSpace(filenamePath) ? bu.PathForResource(tmpFile, null) : bu.PathForResource(tmpFile, null, filenamePath); return(!string.IsNullOrWhiteSpace(path)); }); if (bundle != null) { file = tmpFile; break; } scale--; } } token.ThrowIfCancellationRequested(); if (file == null) { var tmpFile = string.Format(filename + extension); file = tmpFile; bundle = NSBundle._AllBundles.FirstOrDefault(bu => { var path = string.IsNullOrWhiteSpace(filenamePath) ? bu.PathForResource(tmpFile, null) : bu.PathForResource(tmpFile, null, filenamePath); return(!string.IsNullOrWhiteSpace(path)); }); } token.ThrowIfCancellationRequested(); if (bundle != null) { var path = bundle.PathForResource(file, null); var stream = FileStore.GetInputStream(path, true); var imageInformation = new ImageInformation(); imageInformation.SetPath(identifier); imageInformation.SetFilePath(path); return(new Tuple <Stream, LoadingResult, ImageInformation>( stream, LoadingResult.CompiledResource, imageInformation)); } token.ThrowIfCancellationRequested(); if (string.IsNullOrEmpty(fileType)) { //Asset catalog if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { NSDataAsset asset = null; try { await MainThreadDispatcher.Instance.PostAsync(() => asset = new NSDataAsset(filename)).ConfigureAwait(false); } catch (Exception) { } if (asset != null) { token.ThrowIfCancellationRequested(); var stream = asset.Data?.AsStream(); var imageInformation = new ImageInformation(); imageInformation.SetPath(identifier); imageInformation.SetFilePath(null); return(new Tuple <Stream, LoadingResult, ImageInformation>( stream, LoadingResult.CompiledResource, imageInformation)); } } else if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { UIImage image = null; try { await MainThreadDispatcher.Instance.PostAsync(() => image = UIImage.FromBundle(filename)).ConfigureAwait(false); } catch (Exception) { } if (image != null) { token.ThrowIfCancellationRequested(); var stream = image.AsPNG()?.AsStream(); var imageInformation = new ImageInformation(); imageInformation.SetPath(identifier); imageInformation.SetFilePath(null); return(new Tuple <Stream, LoadingResult, ImageInformation>( stream, LoadingResult.CompiledResource, imageInformation)); } } } } throw new FileNotFoundException(identifier); }
protected void CalculateFolderRemainMB(HttpServerUtilityBase server, FileStore fileStore) { string absoluteFolderPath; string relativeFolderPath; int folderQuota; GetFolderPath(server, fileStore, out absoluteFolderPath, out relativeFolderPath, out folderQuota); var folderSize = (int)Math.Ceiling(FileService.DirSize(absoluteFolderPath, true) / 1048576M); FolderRemainMB = folderQuota - folderSize; }
private void load() { dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures")))); dependencies.Cache(this); dependencies.Cache(LocalConfig); runMigrations(); dependencies.Cache(API = new APIAccess { Username = LocalConfig.Get <string>(OsuSetting.Username), Token = LocalConfig.Get <string>(OsuSetting.Token) }); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory.GetContext)); dependencies.Cache(FileStore = new FileStore(contextFactory.GetContext, Host.Storage)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory.GetContext, RulesetStore, API, Host)); dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, contextFactory.GetContext, Host, BeatmapManager, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory.GetContext, RulesetStore)); dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap); BeatmapManager.DefaultBeatmap = defaultBeatmap; // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); Beatmap.ValueChanged += b => { var trackLoaded = lastBeatmap?.TrackLoaded ?? false; // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (!trackLoaded || lastBeatmap?.Track != b.Track) { if (trackLoaded) { Debug.Assert(lastBeatmap != null); Debug.Assert(lastBeatmap.Track != null); lastBeatmap.RecycleTrack(); } Audio.Track.AddItem(b.Track); } lastBeatmap = b; }; API.Register(this); FileStore.Cleanup(); }
private void GetFolderPath(HttpServerUtilityBase server, FileStore fileStore, out string absoluteFolderPath, out string relativeFolderPath, out int folderQuota) { switch (fileStore) { case FileStore.Videos: absoluteFolderPath = FileService.GetAbsoluteFilePath(server, VideosStore); relativeFolderPath = VideosStore; folderQuota = Properties.Settings.Default.VideosFolderQuotaMB; break; case FileStore.Manuals: absoluteFolderPath = FileService.GetAbsoluteFilePath(server, ManualsStore); relativeFolderPath = ManualsStore; folderQuota = Properties.Settings.Default.ManualsFolderQuotaMB; break; default: throw new ArgumentOutOfRangeException("fileStore"); } }
public AController(AContext context, FileStore fileStore, ILogger <AController> logger) { _aContext = context; _fileStore = fileStore; _logger = logger; }
public void Setup() { var cache = new FilesystemCache("test"); cache.Clear(); _sut = new FileStore(cache); }
private void load() { Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage)); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(largeStore); dependencies.CacheAs(this); dependencies.Cache(LocalConfig); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio)); dependencies.CacheAs <ISkinSource>(SkinManager); API = new APIAccess(LocalConfig); dependencies.CacheAs <IAPIProvider>(API); var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Host.Storage, contextFactory, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap)); // this should likely be moved to ArchiveModelManager when another case appers where it is necessary // to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to // allow lookups to be done on the child (ScoreManager in this case) to perform the cascading delete. List <ScoreInfo> getBeatmapScores(BeatmapSetInfo set) { var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList(); return(ScoreManager.QueryScores(s => beatmapIds.Contains(s.Beatmap.ID)).ToList()); } BeatmapManager.ItemRemoved += i => ScoreManager.Delete(getBeatmapScores(i), true); BeatmapManager.ItemAdded += (i, existing) => ScoreManager.Undelete(getBeatmapScores(i), true); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(new OsuColour()); fileImporters.Add(BeatmapManager); fileImporters.Add(ScoreManager); fileImporters.Add(SkinManager); // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); beatmap = new OsuBindableBeatmap(defaultBeatmap); dependencies.CacheAs <IBindable <WorkingBeatmap> >(beatmap); dependencies.CacheAs(beatmap); FileStore.Cleanup(); AddInternal(API); GlobalActionContainer globalBinding; MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; MenuCursorContainer.Child = globalBinding = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; base.Content.Add(new ScalingContainer(ScalingMode.Everything) { Child = MenuCursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); PreviewTrackManager previewTrackManager; dependencies.Cache(previewTrackManager = new PreviewTrackManager()); Add(previewTrackManager); }
private static Task DownloadScorecardAsync(ScorecardDetails details, FileStore dataStore) { Log.InfoFormat("Fetching URL {0}", details.ScorecardUrl); return Task.Factory.StartNew(() => WebClient.FetchWebPageContent(details.ScorecardUrl)) .ContinueWith(t => SaveScorecard(details, t, dataStore)); }
protected static CrawlResults GetCrawlResultsForSeason(FileStore dataStore, Season season) { return(dataStore.Load <CrawlResults>("crawler/" + season.Name)); }