-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathResourceLoaderBase.cs
48 lines (43 loc) · 1.47 KB
/
ResourceLoaderBase.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
// <copyright file="ResourceLoaderBase.cs" company="Software Antics">
// Copyright (c) Software Antics. All rights reserved.
// </copyright>
namespace FinalEngine.Resources;
using System;
/// <summary>
/// Provides an abstract class used to load resources of the specified <typeparamref name="TResource"/> type.
/// </summary>
///
/// <typeparam name="TResource">
/// The type of the resource to load.
/// </typeparam>
///
/// <remarks>
/// You should implement this interface if there is a resource type you wish to load via an <see cref="IResourceManager"/>. Please note that the implementation should (usually) be able to function without a resource manager.
/// </remarks>
///
/// <seealso cref="IResourceLoader" />
public abstract class ResourceLoaderBase<TResource> : IResourceLoader
where TResource : IResource
{
Type IResourceLoader.GetResourceType()
{
return typeof(TResource);
}
/// <summary>
/// Loads a resource from the specified <paramref name="filePath"/>.
/// </summary>
///
/// <param name="filePath">
/// The file path of the resource to load.
/// </param>
///
/// <returns>
/// The loaded resource, of type <typeparamref name="TResource"/>.
/// </returns>
public abstract TResource LoadResource(string filePath);
IResource IResourceLoader.LoadResource(string filePath)
{
ArgumentException.ThrowIfNullOrWhiteSpace(filePath, nameof(filePath));
return this.LoadResource(filePath);
}
}