-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathIResourceManager.cs
70 lines (64 loc) · 2.56 KB
/
IResourceManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// <copyright file="IResourceManager.cs" company="Software Antics">
// Copyright (c) Software Antics. All rights reserved.
// </copyright>
namespace FinalEngine.Resources;
using System;
using FinalEngine.Resources.Exceptions;
/// <summary>
/// Defines an interface that represents a resource manager.
/// </summary>
///
/// <remarks>
/// In almost all scenarios you should never have to implement this interface; if you require management of resources you should use the standard <see cref="ResourceManager"/> implementation.
/// </remarks>
///
/// <seealso cref="System.IDisposable" />
public interface IResourceManager : IDisposable
{
/// <summary>
/// Loads a resource at the specified <paramref name="filePath"/>.
/// </summary>
/// <typeparam name="T">
/// The type of resource to load.
/// </typeparam>
///
/// <param name="filePath">
/// The file path of the resource to load.
/// </param>
///
/// <remarks>
/// The typical implementation of <see cref="IResourceManager"/> should attempt to cache resources; this way if <see cref="LoadResource{T}(string)"/> is called for the same file a reference the already loaded resource can be fetched.
/// </remarks>
///
/// <returns>
/// The loaded resource, of type <typeparamref name="T"/>.
/// </returns>
T LoadResource<T>(string filePath)
where T : IResource;
/// <summary>
/// Registers the specified <paramref name="loader"/> to this <see cref="IResourceManager"/>.
/// </summary>
///
/// <typeparam name="T">
/// The type of resource that can be loaded.
/// </typeparam>
///
/// <param name="loader">
/// The resource loader to be used when attempting to resolve a resource of type <typeparamref name="T"/>.
/// </param>
///
/// <remarks>
/// The typical implementation of an <see cref="IResourceManager"/> should likely throw a <see cref="ResourceLoaderNotRegisteredException"/> if a loader of the specified <typeparamref name="T"/> type has already been registered.
/// </remarks>
void RegisterLoader<T>(ResourceLoaderBase<T> loader)
where T : IResource;
void RegisterLoader(Type type, IResourceLoader loader);
/// <summary>
/// Unloads the specified <paramref name="resource"/> from this <see cref="IResourceManager"/> (calling it's dispose method if <see cref="IDisposable"/> is implemented and there are no references).
/// </summary>
///
/// <param name="resource">
/// The resource to unload.
/// </param>
void UnloadResource(IResource resource);
}