GetFromFile without FileInfo (#1913)

* GetFromFile without FileInfo

* Implement missing interface member
This commit is contained in:
RyouBakura 2024-07-24 20:07:23 +02:00 committed by GitHub
parent 426eaec0f2
commit def28b37c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View file

@ -45,6 +45,10 @@ internal sealed partial class TextureManager
ISharedImmediateTexture ITextureProvider.GetFromFile(FileInfo file) =>
this.Shared.GetFromFile(file);
/// <inheritdoc/>
public ISharedImmediateTexture GetFromFileAbsolute(string fullPath) =>
this.Shared.GetFromFileAbsolute(fullPath);
/// <inheritdoc/>
ISharedImmediateTexture ITextureProvider.GetFromManifestResource(Assembly assembly, string name) =>
this.Shared.GetFromManifestResource(assembly, name);
@ -141,7 +145,12 @@ internal sealed partial class TextureManager
/// <inheritdoc cref="ITextureProvider.GetFromFile(FileInfo)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public SharedImmediateTexture.PureImpl GetFromFile(FileInfo file) =>
this.fileDict.GetOrAdd(file.FullName, FileSystemSharedImmediateTexture.CreatePlaceholder)
this.GetFromFileAbsolute(file.FullName);
/// <inheritdoc cref="ITextureProvider.GetFromFileAbsolute(string)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public SharedImmediateTexture.PureImpl GetFromFileAbsolute(string fullPath) =>
this.fileDict.GetOrAdd(fullPath, FileSystemSharedImmediateTexture.CreatePlaceholder)
.PublicUseInstance;
/// <inheritdoc cref="ITextureProvider.GetFromManifestResource"/>

View file

@ -313,6 +313,14 @@ internal sealed class TextureManagerPluginScoped
return shared;
}
/// <inheritdoc/>
public ISharedImmediateTexture GetFromFileAbsolute(string fullPath)
{
var shared = this.ManagerOrThrow.Shared.GetFromFileAbsolute(fullPath);
shared.AddOwnerPlugin(this.plugin);
return shared;
}
/// <inheritdoc/>
public ISharedImmediateTexture GetFromManifestResource(Assembly assembly, string name)
{