/// <summary> /// Clears all of the registered dependencies for the specified asset. /// </summary> /// <param name="asset">The asset identifier of the asset for which to clear dependencies.</param> public void ClearAssetDependencies(AssetID asset) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); Contract.EnsureNotDisposed(this, Disposed); ClearAssetDependencies(AssetID.GetAssetPath(asset)); }
/// <summary> /// Sets the flags associated with the specified asset. /// </summary> /// <param name="asset">The asset identifier of the asset for which to retrieve flags.</param> /// <param name="flags">A collection of <see cref="AssetFlags"/> value associated with the specified asset.</param> /// <returns><see langword="true"/> if the specified asset has flags defined within this /// content manager; otherwise, <see langword="false"/>.</returns> internal Boolean GetAssetFlags(AssetID asset, out AssetFlags flags) { Contract.EnsureNotDisposed(this, Disposed); lock (SyncObject) return(assetFlags.TryGetValue(AssetID.GetAssetPath(asset), out flags)); }
/// <summary> /// Sets the flags associated with the specified asset. /// </summary> /// <param name="asset">The asset identifier of the asset for which to set flags.</param> /// <param name="flags">A collection of <see cref="AssetFlags"/> values to associate with the specified asset.</param> internal void SetAssetFlags(AssetID asset, AssetFlags flags) { Contract.EnsureNotDisposed(this, Disposed); lock (SyncObject) assetFlags[AssetID.GetAssetPath(asset)] = flags; }
/// <summary> /// Adds the specified dependency to an asset. If the asset is being watched for changes, then any /// changes to the specified dependency will also cause the main asset to be reloaded. /// </summary> /// <param name="asset">The asset identifier of the asset for which to add a dependency.</param> /// <param name="dependency">The asset identifier of the dependency to add to the specified asset.</param> /// <param name="density">The screen density of the assets for which to add a dependency.</param> public void AddAssetDependency(AssetID asset, AssetID dependency, ScreenDensityBucket density) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); Contract.Ensure <ArgumentException>(dependency.IsValid, nameof(dependency)); Contract.EnsureNotDisposed(this, Disposed); AddAssetDependencyInternal(AssetID.GetAssetPath(asset), AssetID.GetAssetPath(dependency), density); }
/// <summary> /// Gets a value indicating whether the specified asset is registered as a dependency of another asset. /// </summary> /// <param name="asset">The asset identifier of the main asset to evaluate.</param> /// <param name="dependency">The file path of the dependency asset to evaluate.</param> /// <param name="density">The screen density for which to query dependency relationships.</param> /// <returns><see langword="true"/> if <paramref name="dependency"/> is a dependency of <paramref name="asset"/>; otherwise, <see langword="false"/>.</returns> public Boolean IsAssetDependencyPath(AssetID asset, String dependency, ScreenDensityBucket density) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); Contract.Require(dependency, nameof(dependency)); Contract.EnsureNotDisposed(this, Disposed); return(IsAssetDependencyPathInternal(AssetID.GetAssetPath(asset), dependency, density)); }
/// <summary> /// Adds a watcher for the specified asset. /// </summary> /// <param name="asset">The asset identifier of the asset for which to add a watcher.</param> /// <param name="watcher">The watcher to add for the specified asset.</param> /// <returns><see langword="true"/> if the watcher was added; otherwise, <see langword="false"/>.</returns> public Boolean AddWatcher <TOutput>(AssetID asset, AssetWatcher <TOutput> watcher) { Contract.Require(watcher, nameof(watcher)); var primaryDisplay = ContentManager.Ultraviolet.GetPlatform().Displays.PrimaryDisplay; var primaryDisplayDensityBucket = primaryDisplay?.DensityBucket ?? ScreenDensityBucket.Desktop; return(AddWatcherInternal(AssetID.GetAssetPath(asset), primaryDisplayDensityBucket, watcher)); }
/// <summary> /// Gets a <see cref="WatchedAsset{T}"/> which watches the specified asset. The <see cref="WatchedAsset{T}"/> which is returned /// is owned by the content manager and shared between all callers of this method. If the watched asset has not already been /// loaded, it will be loaded and added to the content manager's internal cache. /// </summary> /// <typeparam name="TOutput">The type of object being loaded.</typeparam> /// <param name="asset">The identifier of the asset to load.</param> /// <returns>The <see cref="WatchedAsset{T}"/> instance which this content manager uses to watch the specified asset.</returns> public WatchedAsset <TOutput> GetSharedWatchedAsset <TOutput>(AssetID asset) { Contract.EnsureNotDisposed(this, Disposed); var primaryDisplay = Ultraviolet.GetPlatform().Displays.PrimaryDisplay; var primaryDisplayDensity = primaryDisplay.DensityBucket; return(GetSharedWatchedAssetInternal <TOutput>(AssetID.GetAssetPath(asset), primaryDisplayDensity)); }
/// <summary> /// Adds the specified dependency to an asset. If the asset is being watched for changes, then any /// changes to the specified dependency will also cause the main asset to be reloaded. /// </summary> /// <param name="asset">The asset identifier of the asset for which to add a dependency.</param> /// <param name="dependency">The asset identifier of the dependency to add to the specified asset.</param> public void AddAssetDependency(AssetID asset, AssetID dependency) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); Contract.Ensure <ArgumentException>(dependency.IsValid, nameof(dependency)); Contract.EnsureNotDisposed(this, Disposed); var primaryDisplay = Ultraviolet.GetPlatform().Displays.PrimaryDisplay; var primaryDisplayDensity = primaryDisplay?.DensityBucket ?? ScreenDensityBucket.Desktop; AddAssetDependencyInternal(AssetID.GetAssetPath(asset), AssetID.GetAssetPath(dependency), primaryDisplayDensity); }
/// <summary> /// Gets a value indicating whether the specified asset is registered as a dependency of another asset. /// </summary> /// <param name="asset">The asset identifier of the main asset to evaluate.</param> /// <param name="dependency">The file path of the dependency asset to evaluate.</param> /// <returns><see langword="true"/> if <paramref name="dependency"/> is a dependency of <paramref name="asset"/>; otherwise, <see langword="false"/>.</returns> public Boolean IsAssetDependencyPath(AssetID asset, String dependency) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); Contract.Require(dependency, nameof(dependency)); Contract.EnsureNotDisposed(this, Disposed); var primaryDisplay = Ultraviolet.GetPlatform().Displays.PrimaryDisplay; var primaryDisplayDensity = primaryDisplay?.DensityBucket ?? ScreenDensityBucket.Desktop; return(IsAssetDependencyPathInternal(AssetID.GetAssetPath(asset), dependency, primaryDisplayDensity)); }
/// <summary> /// Adds a watcher for the specified asset. /// </summary> /// <param name="asset">The asset identifier of the asset for which to add a watcher.</param> /// <param name="density">The density bucket corresponding to the version of the asset to watch.</param> /// <param name="watcher">The watcher to add for the specified asset.</param> /// <returns><see langword="true"/> if the watcher was added; otherwise, <see langword="false"/>.</returns> public Boolean AddWatcher <TOutput>(AssetID asset, ScreenDensityBucket density, AssetWatcher <TOutput> watcher) { Contract.Require(watcher, nameof(watcher)); return(AddWatcherInternal(AssetID.GetAssetPath(asset), density, watcher)); }
/// <summary> /// Gets a <see cref="WatchedAsset{T}"/> which watches the specified asset. The <see cref="WatchedAsset{T}"/> which is returned /// is owned by the content manager and shared between all callers of this method. If the watched asset has not already been /// loaded, it will be loaded and added to the content manager's internal cache. /// </summary> /// <typeparam name="TOutput">The type of object being loaded.</typeparam> /// <param name="asset">The identifier of the asset to load.</param> /// <param name="density">The screen density for which to retrieve an asset watcher.</param> /// <returns>The <see cref="WatchedAsset{T}"/> instance which this content manager uses to watch the specified asset.</returns> public WatchedAsset <TOutput> GetSharedWatchedAsset <TOutput>(AssetID asset, ScreenDensityBucket density) { Contract.EnsureNotDisposed(this, Disposed); return(GetSharedWatchedAssetInternal <TOutput>(AssetID.GetAssetPath(asset), density)); }
/// <summary> /// Purges the specified asset from the content manager's internal cache. /// </summary> /// <param name="asset">The asset to purge from the cache.</param> /// <param name="lowMemory">A value indicating whether the cache is being purged due to the operating system /// being low on memory. If this value is <see langword="true"/>, then assets which have the /// <see cref="AssetFlags.PreserveThroughLowMemory"/> flag will be ignored by this method. Otherwise, /// all of the cache's assets will be purged.</param> public void PurgeAsset(AssetID asset, Boolean lowMemory) { Contract.Ensure <ArgumentException>(asset.IsValid, nameof(asset)); PurgeAsset(AssetID.GetAssetPath(asset), lowMemory); }