private static int RunAccessesConcurrently(string[] keys) { var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name)); var lck = new object(); var concurrentCallCount = 0; var maxCallCount = 0; var threads = new List<Thread>(); foreach (var key in keys) { var thisKey = key; var thread = new Thread(() => resourceStore.Access(thisKey, item => { lock (lck) { concurrentCallCount++; maxCallCount = Math.Max(maxCallCount, concurrentCallCount); } Thread.Sleep(250); lock (lck) { concurrentCallCount--; } })); thread.Start(); threads.Add(thread); } foreach (var thread in threads) { thread.Join(); } return maxCallCount; }
public void CacheCanCloseBeforeGet() { var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name)); resourceStore.Close("foo"); Assert.Throws<ObjectDisposedException>(() => resourceStore.Access("foo", it => { })); }
public void CacheReturnsSameInstanceWhenCalledTwice() { var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name)); Disposable firstItem = null; resourceStore.Access("foo", item => firstItem = item); Assert.AreEqual("foo", firstItem.Name); Disposable secondItem = null; resourceStore.Access("foo", item => secondItem = item); Assert.AreSame(firstItem, secondItem); }
public void CacheCanCloseItemsEarly() { var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name)); Disposable item1 = null; Disposable item2 = null; resourceStore.Access("foo", it => item1 = it); resourceStore.Access("bar", it => item2 = it); Assert.AreEqual(0, item1.DisposeCallCount); Assert.AreEqual(0, item2.DisposeCallCount); resourceStore.Close("foo"); Assert.AreEqual(1, item1.DisposeCallCount); Assert.AreEqual(0, item2.DisposeCallCount); Assert.Throws<ObjectDisposedException>(() => resourceStore.Access("foo", it => { })); resourceStore.Dispose(); Assert.AreEqual(1, item1.DisposeCallCount); Assert.AreEqual(1, item2.DisposeCallCount); }
/** * Standard procedure to compile resources: * 1. Get an AppDomain correspondint to the Classloader. * 2. Create an assembly in the given appdomain * 3. Create a type for each resource, given the className (resourceName), contents * (pReader.getBytes(resourceName)), and the AppDomain. * 4. Write the compiled types to the store. */ public override CompilationResult compile( string[] pResourceNames, ResourceReader pReader, ResourceStore pStore, ClassLoader pClassLoader ) { int OFFSETCONSTANT = 8; Type[] types = new Type[pResourceNames.Length]; string[] contents = new string[pResourceNames.Length]; CodeSnippetCompileUnit[] units = new CodeSnippetCompileUnit[pResourceNames.Length]; for (int i = 0; i < types.Length; i++) { string resourceName = pResourceNames[i].Replace('.', '/') + ".java"; byte[] byteArray = pReader.getBytes(resourceName); string fileContents = this.StringFromBytes(byteArray); units[i] = new CodeSnippetCompileUnit(fileContents.Replace("cli.", "")); if (fileContents.Contains("public static void consequence")) { object[] info = this.GetLinePragmaInfo(fileContents, OFFSETCONSTANT); if (info != null) { units[i].LinePragma = new CodeLinePragma(info[0] as string, (int)info[1]); } } } CodeDomProvider provider = GetProvider(); CompilerParameters compilerParameters = new CompilerParameters(); compilerParameters.GenerateInMemory = true; compilerParameters.IncludeDebugInformation = true; // compilerParameters.OutputAssembly = pResourceNames[i].Substring(pResourceNames[i].LastIndexOf('.') + 1); int count = 0; foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (assembly.FullName.StartsWith("CompiledRules")) { try { File.Delete(assembly.Location); } catch (System.Exception e) { count++; } } else { compilerParameters.ReferencedAssemblies.Add(assembly.Location); } } compilerParameters.OutputAssembly = "CompiledRules" + count + ".dll"; CompilerResults results = provider.CompileAssemblyFromDom //(compilerParameters, contents); (compilerParameters, units); Collection problems = new ArrayList(); DotnetPackageCompilationData pcData = (DotnetPackageCompilationData) ((PackageStore)pStore).getPackageCompilationData(); MemoryStream stream = new MemoryStream(1024); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, results.CompiledAssembly); for (int i = 0; i < types.Length; i++) { string resourceName = pResourceNames[i]; pcData.write(resourceName, new object[] { results.CompiledAssembly, stream.GetBuffer() }); } CompilationProblem[] result = new CompilationProblem[problems.size()]; return(new CompilationResult(result)); }
public CytusRuleset(RulesetInfo rulesetInfo = null) : base(rulesetInfo) { ResourceStore = new NamespacedResourceStore <byte[]>(new DllResourceStore("osu.Game.Rulesets.HoLLy.Cytus.dll"), "Resources"); TextureStore = new TextureStore(new TextureLoaderStore(new NamespacedResourceStore <byte[]>(ResourceStore, "Textures"))); }
public void OneTimeSetUp() { storage = new TemporaryNativeStorage("fontstore-test"); fontResourceStore = new NamespacedResourceStore <byte[]>(new DllResourceStore(typeof(Drawable).Assembly), "Resources.Fonts.Roboto"); }
private void addFont(FontStore target, ResourceStore <byte[]> store, string assetName = null) => target.AddStore(new RawCachingGlyphStore(store, assetName, Host.CreateTextureLoaderStore(store)));
private void load(FrameworkConfigManager config) { Resources = new ResourceStore <byte[]>(); Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(typeof(Game).Assembly), @"Resources")); Textures = new TextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures"))); Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); dependencies.Cache(Textures); var tracks = new ResourceStore <byte[]>(); tracks.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Tracks")); tracks.AddStore(new OnlineStore()); var samples = new ResourceStore <byte[]>(); samples.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Samples")); samples.AddStore(new OnlineStore()); Audio = new AudioManager(Host.AudioThread, tracks, samples) { EventScheduler = Scheduler }; dependencies.Cache(Audio); dependencies.CacheAs(Audio.Tracks); dependencies.CacheAs(Audio.Samples); // attach our bindables to the audio subsystem. config.BindWith(FrameworkSetting.AudioDevice, Audio.AudioDevice); config.BindWith(FrameworkSetting.VolumeUniversal, Audio.Volume); config.BindWith(FrameworkSetting.VolumeEffect, Audio.VolumeSample); config.BindWith(FrameworkSetting.VolumeMusic, Audio.VolumeTrack); Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders")); dependencies.Cache(Shaders); var cacheStorage = Host.CacheStorage.GetStorageForDirectory("fonts"); // base store is for user fonts Fonts = new FontStore(useAtlas: true, cacheStorage: cacheStorage); // nested store for framework provided fonts. // note that currently this means there could be two async font load operations. Fonts.AddStore(localFonts = new FontStore(useAtlas: false)); // Roboto (FrameworkFont.Regular) addFont(localFonts, Resources, @"Fonts/Roboto/Roboto-Regular"); addFont(localFonts, Resources, @"Fonts/Roboto/Roboto-RegularItalic"); addFont(localFonts, Resources, @"Fonts/Roboto/Roboto-Bold"); addFont(localFonts, Resources, @"Fonts/Roboto/Roboto-BoldItalic"); // RobotoCondensed (FrameworkFont.Condensed) addFont(localFonts, Resources, @"Fonts/RobotoCondensed/RobotoCondensed-Regular"); addFont(localFonts, Resources, @"Fonts/RobotoCondensed/RobotoCondensed-Bold"); addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Solid"); addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Regular"); addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Brands"); dependencies.Cache(Fonts); Localisation = new LocalisationManager(config); dependencies.Cache(Localisation); frameSyncMode = config.GetBindable <FrameSync>(FrameworkSetting.FrameSync); executionMode = config.GetBindable <ExecutionMode>(FrameworkSetting.ExecutionMode); logOverlayVisibility = config.GetBindable <bool>(FrameworkSetting.ShowLogOverlay); logOverlayVisibility.BindValueChanged(visibility => { if (visibility.NewValue) { if (logOverlay == null) { LoadComponentAsync(logOverlay = new LogOverlay { Depth = float.MinValue / 2, }, AddInternal); } logOverlay.Show(); } else { logOverlay?.Hide(); } }, true); }
/// <summary> /// Constructs an AudioManager given a track resource store, and a sample resource store. /// </summary> /// <param name="audioThread">The host's audio thread.</param> /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param> /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param> public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) { Thread = audioThread; Thread.RegisterManager(this); AudioDevice.ValueChanged += onDeviceChanged; trackStore.AddExtension(@"mp3"); sampleStore.AddExtension(@"wav"); sampleStore.AddExtension(@"mp3"); globalTrackManager = new Lazy <TrackManager>(() => GetTrackManager(trackStore)); globalSampleManager = new Lazy <SampleManager>(() => GetSampleManager(sampleStore)); scheduler.Add(() => { try { setAudioDevice(); } catch { } }); scheduler.AddDelayed(delegate { updateAvailableAudioDevices(); checkAudioDeviceChanged(); }, 1000, true); }
private void load(FrameworkConfigManager config) { if (!AssetsLoaded) { AssetsLoaded = true; VitaruResources = new ResourceStore <byte[]>(); VitaruResources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore("osu.Game.Rulesets.Vitaru.dll"), ("Assets"))); VitaruResources.AddStore(new DllResourceStore("osu.Game.Rulesets.Vitaru.dll")); VitaruTextures = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore <byte[]>(VitaruResources, @"Textures"))); VitaruTextures.AddStore(new RawTextureLoaderStore(new OnlineStore())); //This is wrong, but I am unsure how to add the audio files //Audio = Dependencies.Cache(new SampleManager(new NamespacedResourceStore<byte[]>(Resources, @"Audio/Samples"))); } //Drawable stuff loading for each individual Character Anchor = Anchor.TopLeft; Origin = Anchor.Centre; Children = new Drawable[] { CharacterSprite = new Sprite() { Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 1, }, CharacterKiaiSprite = new Sprite() { Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0, }, Hitbox = new Hitbox() { Alpha = 0, HitboxWidth = HitboxWidth, HitboxColor = HitboxColor, }, CharacterSign = new Sprite() { Alpha = 0, Anchor = Anchor.Centre, Origin = Anchor.Centre, } }; string characterType = "null"; switch (CharacterType) { case HitObjectType.Player: characterType = "player"; break; case HitObjectType.Enemy: characterType = "enemy"; break; case HitObjectType.Boss: characterType = "boss"; break; } //sampleDeath = audio.Sample.Get(@"deathSound"); //sampleShoot = audio.Sample.Get(@"shootSound"); CharacterSprite.Texture = VitaruTextures.Get(characterType); CharacterKiaiSprite.Texture = VitaruTextures.Get(characterType + "Kiai"); CharacterSign.Texture = VitaruTextures.Get(characterType + "Sign"); }
public LevelAudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) : base(audioThread, trackStore, sampleStore) { }
public FileStore(SQLiteConnection connection, Storage storage) : base(connection, storage) { Store = new NamespacedResourceStore <byte[]>(new StorageBackedResourceStore(storage), prefix); }
public FirstLaunchForm() { InitializeComponent(); Icon = ResourceStore.LoadIcon("Icons/Application.ico"); }
Dictionary <string, object> GetResources(string fileName) { Stream s = null; WorkbenchSingleton.SafeThreadCall( delegate { OpenedFile file = FileService.GetOpenedFile(fileName); if (file != null) { s = file.OpenRead(); } }); if (s == null) { s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); } using (s) { using (IResourceReader reader = ResourceStore.CreateResourceReader(s, ResourceStore.GetResourceType(fileName))) { ResXResourceReader resXReader = reader as ResXResourceReader; if (resXReader != null) { resXReader.BasePath = Path.GetDirectoryName(fileName); } var resources = new Dictionary <string, object>(); foreach (System.Collections.DictionaryEntry entry in reader) { if (entry.Value == null) { continue; } if (this.requiredResourceType.IsAssignableFrom(entry.Value.GetType())) { resources.Add((string)entry.Key, entry.Value); } } return(resources); } } }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { options.SetOption(ExportOptionKey.JS_FILE_PREFIX, null); options.SetOption(ExportOptionKey.JS_FULL_PAGE, false); // iOS export has its own enforced fullscreen logic options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, ""); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); Dictionary <string, FileOutput> files = new Dictionary <string, FileOutput>(); Dictionary <string, FileOutput> basicProject = new Dictionary <string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, libraries, resourceDatabase, options); // TODO: not good. The library inclusions should automatically be populated in LangJavaScript platforms. // This is also done identically in the ChromeApp PlatformImpl. replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(basicProject.Keys); foreach (string filePath in basicProject.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath]; } // TODO: use this in the pbxproj file. string uuidSeed = options.GetStringOrNull(ExportOptionKey.GUID_SEED); OrientationParser orientations = new OrientationParser(options); bool useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight; FileOutput launchScreen; if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN)) { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(options.GetString(ExportOptionKey.LAUNCHSCREEN_PATH)), }; } else { string resourcePath = "SwiftResources/" + (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png"); byte[] bytes = new ResourceStore(typeof(JavaScriptAppIos.PlatformImpl)).ReadAssemblyFileBytes(resourcePath); launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(bytes), }; } files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen; replacements["LAUNCH_SCREEN_WIDTH"] = launchScreen.Bitmap.Width.ToString(); replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString(); IconSetGenerator icons = new IconSetGenerator(); if (options.GetBool(ExportOptionKey.HAS_ICON)) { string[] iconPaths = options.GetStringArray(ExportOptionKey.ICON_PATH); foreach (string iconPath in iconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary <int, Bitmap> iconImagesBySize = icons .AddOutputSize(20 * 1) .AddOutputSize(20 * 2) .AddOutputSize(20 * 3) .AddOutputSize(29 * 1) .AddOutputSize(29 * 2) .AddOutputSize(29 * 3) .AddOutputSize(40 * 1) .AddOutputSize(40 * 2) .AddOutputSize(40 * 3) .AddOutputSize(60 * 2) .AddOutputSize(60 * 3) .AddOutputSize(76 * 1) .AddOutputSize(76 * 2) .AddOutputSize(167) // 83.5 * 2 .AddOutputSize(1024) .GenerateWithDefaultFallback(); foreach (int size in iconImagesBySize.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[size], }; } foreach (string pair in new string[] { "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt", }) { string[] parts = pair.Split('|'); files[parts[0]] = new FileOutput() { TrimBomIfPresent = true, Type = FileOutputType.Text, TextContent = this.LoadTextResource(parts[1], replacements), }; } foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
private Locale(string name) { this.ID = name; bool invalid = false; if (name.Length > 100) { for (int i = 0; i < name.Length; ++i) { char c = name[i]; if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')) { invalid = true; break; } } } string keywordsRaw = new ResourceStore(typeof(Locale)).ReadAssemblyFileText("Languages/" + name.ToLowerInvariant() + "/keywords.txt", true); if (keywordsRaw == null) { invalid = true; } if (invalid) { throw new InvalidOperationException("Unknown locale: '" + name + "'"); } Dictionary <string, string> keywords = new Dictionary <string, string>(); foreach (string keywordRow in keywordsRaw.Trim().Split('\n')) { string row = keywordRow.Trim(); if (row.Length > 0) { string[] parts = keywordRow.Split(':'); if (parts.Length != 2) { throw new Exception("Unknown line in keywords: " + keywordRow); } keywords.Add(parts[0].Trim(), parts[1].Trim()); } } this.keywordsDictionary = keywords; this.Keywords = new KeywordsLookup() { Lookup = new HashSet <string>(keywords.Values), ValidIdentifierNames = new HashSet <string>( new string[] { "FIELD_ENUM_LENGTH", "FIELD_ENUM_MAX", "FIELD_ENUM_VALUES", "MAIN_FUNCTION", }.Select(k => keywords[k])), ABSTRACT = keywords["ABSTRACT"], BASE = keywords["BASE"], BREAK = keywords["BREAK"], CASE = keywords["CASE"], CATCH = keywords["CATCH"], CLASS = keywords["CLASS"], CONST = keywords["CONST"], CONSTRUCTOR = keywords["CONSTRUCTOR"], CONTINUE = keywords["CONTINUE"], DEFAULT = keywords["DEFAULT"], DO = keywords["DO"], DO_WHILE_END = keywords["DO_WHILE_END"], ELSE = keywords["ELSE"], ENUM = keywords["ENUM"], FALSE = keywords["FALSE"], FIELD = keywords["FIELD"], FIELD_ENUM_LENGTH = keywords["FIELD_ENUM_LENGTH"], FIELD_ENUM_MAX = keywords["FIELD_ENUM_MAX"], FIELD_ENUM_VALUES = keywords["FIELD_ENUM_VALUES"], FINAL = keywords["FINAL"], FINALLY = keywords["FINALLY"], FOR = keywords["FOR"], FUNCTION = keywords["FUNCTION"], IF = keywords["IF"], IMPORT = keywords["IMPORT"], INTERFACE = keywords["INTERFACE"], IS = keywords["IS"], MAIN_FUNCTION = keywords["MAIN_FUNCTION"], NAMESPACE = keywords["NAMESPACE"], NEW = keywords["NEW"], NULL = keywords["NULL"], PRIVATE = keywords["PRIVATE"], RETURN = keywords["RETURN"], STATIC = keywords["STATIC"], SWITCH = keywords["SWITCH"], THIS = keywords["THIS"], THROW = keywords["THROW"], TRUE = keywords["TRUE"], TRY = keywords["TRY"], WHILE = keywords["WHILE"], }; this.Strings = new StringTable(name); }
public IOSAudioManager(ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) : base(trackStore, sampleStore) { }
public LandResourceEditor(ResourceStore _resourceStore) { resourceStore = _resourceStore; }
public static IList <ResourceStore> GetAllResourceStore() { ResourceStore item = new ResourceStore(); return(rss.GetAllResourceStore(item)); }
public void CacheDisposesAllItemsExactlyOnce() { var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name)); Disposable item1 = null; Disposable item2 = null; resourceStore.Access("foo", it => item1 = it); resourceStore.Access("bar", it => item2 = it); Assert.AreEqual(0, item1.DisposeCallCount); Assert.AreEqual(0, item2.DisposeCallCount); resourceStore.Dispose(); Assert.AreEqual(1, item1.DisposeCallCount); Assert.AreEqual(1, item2.DisposeCallCount); resourceStore.Dispose(); Assert.AreEqual(1, item1.DisposeCallCount); Assert.AreEqual(1, item2.DisposeCallCount); }
public void OneTimeSetUp() { storage = new TemporaryNativeStorage("fontstore-test", createIfEmpty: true); fontResourceStore = new NamespacedResourceStore <byte[]>(new DllResourceStore(typeof(Drawable).Assembly), "Resources.Fonts.OpenSans"); }
protected override TrackManager CreateTrackManager(ResourceStore <byte[]> store) => new IOSTrackManager(store);
public async Task GetAllResources_WhenAllResourcesRequested_ExpectAllResourcesIncludingHidden() { using var ravenStore = GetDocumentStore(); await new ApiResourceIndex().ExecuteAsync(ravenStore); var visibleIdentityResource = CreateIdentityTestResource(); var visibleApiResource = CreateApiResourceTestResource(); var visibleApiScope = CreateApiScopeTestResource(); var hiddenIdentityResource = new IdentityResource { Name = Guid.NewGuid().ToString(), ShowInDiscoveryDocument = false }; var hiddenApiResource = new ApiResource { Name = Guid.NewGuid().ToString(), Scopes = { Guid.NewGuid().ToString() }, ShowInDiscoveryDocument = false }; var hiddenApiScope = new ApiScope { Name = Guid.NewGuid().ToString(), ShowInDiscoveryDocument = false }; using (var session = ravenStore.OpenSession()) { session.Store(visibleIdentityResource.ToEntity()); session.Store(visibleApiResource.ToEntity()); session.Store(visibleApiScope.ToEntity()); session.Store(hiddenIdentityResource.ToEntity()); session.Store(hiddenApiResource.ToEntity()); session.Store(hiddenApiScope.ToEntity()); session.SaveChanges(); } WaitForIndexing(ravenStore); WaitForUserToContinueTheTest(ravenStore); Resources resources; using (var session = ravenStore.OpenAsyncSession()) { var store = new ResourceStore(session, FakeLogger <ResourceStore> .Create()); resources = await store.GetAllResourcesAsync(); } Assert.NotNull(resources); Assert.NotEmpty(resources.IdentityResources); Assert.NotEmpty(resources.ApiResources); Assert.NotEmpty(resources.ApiScopes); Assert.Contains(resources.IdentityResources, x => x.Name == visibleIdentityResource.Name); Assert.Contains(resources.IdentityResources, x => x.Name == hiddenIdentityResource.Name); Assert.Contains(resources.ApiResources, x => x.Name == visibleApiResource.Name); Assert.Contains(resources.ApiResources, x => x.Name == hiddenApiResource.Name); Assert.Contains(resources.ApiScopes, x => x.Name == visibleApiScope.Name); Assert.Contains(resources.ApiScopes, x => x.Name == hiddenApiScope.Name); }
private static string GetPath(string path) => ResourceStore.GetPath("material_presets\\" + path);
/// <summary> /// Constructs an AudioStore given a track resource store, and a sample resource store. /// </summary> /// <param name="audioThread">The host's audio thread.</param> /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param> /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param> public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) { Thread = audioThread; Thread.RegisterManager(this); AudioDevice.ValueChanged += onDeviceChanged; globalTrackStore = new Lazy <TrackStore>(() => { var store = new TrackStore(trackStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack); return(store); }); globalSampleStore = new Lazy <SampleStore>(() => { var store = new SampleStore(sampleStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeSample); return(store); }); // check for device validity every 100ms scheduler.AddDelayed(() => { try { if (!IsCurrentDeviceValid()) { setAudioDevice(); } } catch { } }, 100, true); // enumerate new list of devices every second scheduler.AddDelayed(() => { try { setAudioDevice(AudioDevice.Value); } catch { } }, 1000, true); }
/// <summary> /// Add a font to be globally accessible to the game. /// </summary> /// <param name="store">The backing store with font resources.</param> /// <param name="assetName">The base name of the font.</param> /// <param name="target">An optional target store to add the font to. If not specified, <see cref="Fonts"/> is used.</param> public void AddFont(ResourceStore <byte[]> store, string assetName = null, FontStore target = null) => addFont(target ?? Fonts, store, assetName);
/// <summary> /// Constructs an AudioStore given a track resource store, and a sample resource store. /// </summary> /// <param name="audioThread">The host's audio thread.</param> /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param> /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param> public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) { Thread = audioThread; Thread.RegisterManager(this); AudioDevice.ValueChanged += onDeviceChanged; globalTrackStore = new Lazy <TrackStore>(() => { var store = new TrackStore(trackStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack); return(store); }); globalSampleStore = new Lazy <SampleStore>(() => { var store = new SampleStore(sampleStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeSample); return(store); }); scheduler.Add(() => { try { setAudioDevice(); } catch { } }); scheduler.AddDelayed(delegate { updateAvailableAudioDevices(); checkAudioDeviceChanged(); }, 1000, true); }
public override AudioManager CreateAudioManager(ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore, Scheduler eventScheduler) => new IOSAudioManager(trackStore, sampleStore) { EventScheduler = eventScheduler };
public ShaderManager(ResourceStore <byte[]> store) { this.store = store; }
private static PdfDocument OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, bool isLenientParsing, IReadOnlyList <string> passwords) { var filterProvider = new MemoryFilterProvider(new DecodeParameterResolver(log), new PngPredictor(), log); CrossReferenceTable crossReferenceTable = null; var bruteForceSearcher = new BruteForceSearcher(inputBytes); var xrefValidator = new XrefOffsetValidator(log); var objectChecker = new XrefCosOffsetChecker(log, bruteForceSearcher); // We're ok with this since our intent is to lazily load the cross reference table. // ReSharper disable once AccessToModifiedClosure var locationProvider = new ObjectLocationProvider(() => crossReferenceTable, bruteForceSearcher); var pdfScanner = new PdfTokenScanner(inputBytes, locationProvider, filterProvider, NoOpEncryptionHandler.Instance); var crossReferenceStreamParser = new CrossReferenceStreamParser(filterProvider); var crossReferenceParser = new CrossReferenceParser(log, xrefValidator, objectChecker, crossReferenceStreamParser, new CrossReferenceTableParser()); var version = FileHeaderParser.Parse(scanner, isLenientParsing, log); var crossReferenceOffset = FileTrailerParser.GetFirstCrossReferenceOffset(inputBytes, scanner, isLenientParsing) + version.OffsetInFile; // TODO: make this use the scanner. var validator = new CrossReferenceOffsetValidator(xrefValidator); crossReferenceOffset = validator.Validate(crossReferenceOffset, scanner, inputBytes, isLenientParsing); crossReferenceTable = crossReferenceParser.Parse(inputBytes, isLenientParsing, crossReferenceOffset, version.OffsetInFile, pdfScanner, scanner); var fontDescriptorFactory = new FontDescriptorFactory(); var(rootReference, rootDictionary) = ParseTrailer(crossReferenceTable, isLenientParsing, pdfScanner, out var encryptionDictionary); var encryptionHandler = encryptionDictionary != null ? (IEncryptionHandler) new EncryptionHandler(encryptionDictionary, crossReferenceTable.Trailer, passwords) : NoOpEncryptionHandler.Instance; pdfScanner.UpdateEncryptionHandler(encryptionHandler); var cidFontFactory = new CidFontFactory(pdfScanner, fontDescriptorFactory, filterProvider); var encodingReader = new EncodingReader(pdfScanner); var type1Handler = new Type1FontHandler(pdfScanner, filterProvider, fontDescriptorFactory, encodingReader); var fontFactory = new FontFactory(log, new Type0FontHandler(cidFontFactory, filterProvider, pdfScanner), new TrueTypeFontHandler(log, pdfScanner, filterProvider, fontDescriptorFactory, encodingReader, new SystemFontFinder(), type1Handler), type1Handler, new Type3FontHandler(pdfScanner, filterProvider, encodingReader)); var resourceContainer = new ResourceStore(pdfScanner, fontFactory); var information = DocumentInformationFactory.Create(pdfScanner, crossReferenceTable.Trailer); var catalog = CatalogFactory.Create(rootReference, rootDictionary, pdfScanner, isLenientParsing); var pageFactory = new PageFactory(pdfScanner, resourceContainer, filterProvider, new PageContentParser(new ReflectionGraphicsStateOperationFactory()), log); var caching = new ParsingCachingProviders(bruteForceSearcher, resourceContainer); var acroFormFactory = new AcroFormFactory(pdfScanner, filterProvider); var bookmarksProvider = new BookmarksProvider(log, pdfScanner, isLenientParsing); return(new PdfDocument(log, inputBytes, version, crossReferenceTable, isLenientParsing, caching, pageFactory, catalog, information, encryptionDictionary, pdfScanner, filterProvider, acroFormFactory, bookmarksProvider)); }
public SaveFile() { locationPath = Application.persistentDataPath + "/Saves/"; res = new ResourceStore(); }
/// <summary> /// Constructs an AudioStore given a track resource store, and a sample resource store. /// </summary> /// <param name="audioThread">The host's audio thread.</param> /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param> /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param> public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore) { thread = audioThread; thread.RegisterManager(this); AudioDevice.ValueChanged += onDeviceChanged; globalTrackStore = new Lazy <TrackStore>(() => { var store = new TrackStore(trackStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack); return(store); }); globalSampleStore = new Lazy <SampleStore>(() => { var store = new SampleStore(sampleStore); AddItem(store); store.AddAdjustment(AdjustableProperty.Volume, VolumeSample); return(store); }); CancellationToken token = cancelSource.Token; scheduler.Add(() => { // sync audioDevices every 1000ms new Thread(() => { while (!token.IsCancellationRequested) { try { syncAudioDevices(); Thread.Sleep(1000); } catch { } } }) { IsBackground = true }.Start(); }); }
/// <summary> /// Add a font to be globally accessible to the game. /// </summary> /// <param name="store">The backing store with font resources.</param> /// <param name="assetName">The base name of the font.</param> public void AddFont(ResourceStore <byte[]> store, string assetName = null) => addFont(Fonts, store, assetName);
/** * Standard procedure to compile resources: * 1. Get an AppDomain correspondint to the Classloader. * 2. Create an assembly in the given appdomain * 3. Create a type for each resource, given the className (resourceName), contents (pReader.getBytes(resourceName)), and the AppDomain. * 4. Write the compiled types to the store. */ public override CompilationResult compile( string[] pResourceNames, ResourceReader pReader, ResourceStore pStore, ClassLoader pClassLoader ) { int OFFSETCONSTANT = 8; Type[] types = new Type[pResourceNames.Length]; string[] contents = new string[pResourceNames.Length]; CodeSnippetCompileUnit[] units = new CodeSnippetCompileUnit[pResourceNames.Length]; for (int i = 0; i < types.Length; i++) { string resourceName = pResourceNames[i].Replace('.','/')+".java"; byte[] byteArray = pReader.getBytes(resourceName); string fileContents = this.StringFromBytes(byteArray); units[i] = new CodeSnippetCompileUnit(fileContents.Replace("cli.", "")); if (fileContents.Contains("public static void consequence")) { object[] info = this.GetLinePragmaInfo(fileContents,OFFSETCONSTANT); if(info != null) units[i].LinePragma = new CodeLinePragma(info[0] as string, (int)info[1]); } } CodeDomProvider provider = GetProvider(); CompilerParameters compilerParameters = new CompilerParameters(); compilerParameters.GenerateInMemory = true; compilerParameters.IncludeDebugInformation = true; // compilerParameters.OutputAssembly = pResourceNames[i].Substring(pResourceNames[i].LastIndexOf('.') + 1); int count = 0; foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (assembly.FullName.StartsWith("CompiledRules")) { try { File.Delete(assembly.Location); } catch (System.Exception e) { count++; } } else { compilerParameters.ReferencedAssemblies.Add(assembly.Location); } } compilerParameters.OutputAssembly = "CompiledRules" + count + ".dll"; CompilerResults results = provider.CompileAssemblyFromDom //(compilerParameters, contents); (compilerParameters, units); Collection problems = new ArrayList(); DotnetPackageCompilationData pcData = (DotnetPackageCompilationData) ((PackageStore)pStore).getPackageCompilationData(); MemoryStream stream = new MemoryStream(1024); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, results.CompiledAssembly); for (int i = 0; i < types.Length; i++) { string resourceName = pResourceNames[i]; pcData.write(resourceName, new object[]{results.CompiledAssembly, stream.GetBuffer()}); } CompilationProblem[] result = new CompilationProblem[problems.size()]; return new CompilationResult(result); }
public EncodedStore(ResourceStore <TExternal> store, Encoder <TInternal, TExternal> encoder) { this.store = store; this.encoder = encoder; }