mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(GameRes): added priorities to format imports.
This commit is contained in:
parent
50606a056a
commit
0ed70e3595
@ -41,11 +41,8 @@ namespace GameRes
|
||||
private static readonly FormatCatalog m_instance = new FormatCatalog();
|
||||
|
||||
#pragma warning disable 649
|
||||
[ImportMany(typeof(ArchiveFormat))]
|
||||
private IEnumerable<ArchiveFormat> m_arc_formats;
|
||||
[ImportMany(typeof(ImageFormat))]
|
||||
private IEnumerable<ImageFormat> m_image_formats;
|
||||
[ImportMany(typeof(AudioFormat))]
|
||||
private IEnumerable<AudioFormat> m_audio_formats;
|
||||
[ImportMany(typeof(ScriptFormat))]
|
||||
private IEnumerable<ScriptFormat> m_script_formats;
|
||||
@ -100,8 +97,12 @@ namespace GameRes
|
||||
//Create the CompositionContainer with the parts in the catalog
|
||||
using (var container = new CompositionContainer (catalog))
|
||||
{
|
||||
m_arc_formats = ImportWithPriorities<ArchiveFormat> (container);
|
||||
m_image_formats = ImportWithPriorities<ImageFormat> (container);
|
||||
m_audio_formats = ImportWithPriorities<AudioFormat> (container);
|
||||
//Fill the imports of this object
|
||||
container.ComposeParts (this);
|
||||
|
||||
AddResourceImpl (m_image_formats, container);
|
||||
AddResourceImpl (m_arc_formats, container);
|
||||
AddResourceImpl (m_audio_formats, container);
|
||||
@ -136,6 +137,14 @@ namespace GameRes
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<Format> ImportWithPriorities<Format> (ExportProvider provider)
|
||||
{
|
||||
return provider.GetExports<Format, IResourceMetadata>()
|
||||
.OrderByDescending (f => f.Metadata.Priority)
|
||||
.Select (f => f.Value)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void AddAliases (ExportProvider provider)
|
||||
{
|
||||
foreach (var alias in provider.GetExports<ResourceAlias, IResourceAliasMetadata>())
|
||||
|
@ -195,6 +195,12 @@ namespace GameRes
|
||||
string Type { get; }
|
||||
}
|
||||
|
||||
public interface IResourceMetadata
|
||||
{
|
||||
[DefaultValue(0)]
|
||||
int Priority { get; }
|
||||
}
|
||||
|
||||
public delegate void ParametersRequestEventHandler (object sender, ParametersRequestEventArgs e);
|
||||
|
||||
public class ParametersRequestEventArgs : EventArgs
|
||||
|
Loading…
x
Reference in New Issue
Block a user