mirror of
https://github.com/crskycode/GARbro.git
synced 2026-06-21 03:15:20 +08:00
GameRes refactoring.
(FormatCatalog.CreateEntry): method renamed to 'Create' and made generic towards Entry type.
This commit is contained in:
@@ -103,7 +103,7 @@ namespace GameRes
|
||||
|
||||
private Entry EntryFromFileInfo (FileInfo file)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (file.FullName);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (file.FullName);
|
||||
entry.Size = (uint)Math.Min (file.Length, uint.MaxValue);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ namespace GameRes
|
||||
/// <summary>
|
||||
/// Create empty Entry that corresponds to implemented resource.
|
||||
/// </summary>
|
||||
public virtual Entry CreateEntry ()
|
||||
public EntryType Create<EntryType> () where EntryType : Entry, new()
|
||||
{
|
||||
return new Entry { Type = this.Type };
|
||||
return new EntryType { Type = this.Type };
|
||||
}
|
||||
|
||||
protected IResource ()
|
||||
@@ -363,19 +363,14 @@ namespace GameRes
|
||||
/// <exception cref="System.ArgumentException">May be thrown if filename contains invalid
|
||||
/// characters.</exception>
|
||||
/// </summary>
|
||||
public Entry CreateEntry (string filename)
|
||||
public EntryType Create<EntryType> (string filename) where EntryType : Entry, new()
|
||||
{
|
||||
Entry entry = null;
|
||||
string ext = Path.GetExtension (filename);
|
||||
if (!string.IsNullOrEmpty (ext))
|
||||
{
|
||||
ext = ext.TrimStart ('.').ToUpperInvariant();
|
||||
var range = m_extension_map.GetValues (ext, false);
|
||||
if (null != range)
|
||||
entry = range.First().CreateEntry();
|
||||
}
|
||||
EntryType entry = null;
|
||||
var formats = LookupFileName (filename);
|
||||
if (formats.Any())
|
||||
entry = formats.First().Create<EntryType>();
|
||||
if (null == entry)
|
||||
entry = new Entry();
|
||||
entry = new EntryType();
|
||||
entry.Name = filename;
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -173,11 +173,6 @@ namespace GameRes
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Entry CreateEntry ()
|
||||
{
|
||||
return new ImageEntry();
|
||||
}
|
||||
|
||||
public bool IsBuiltin
|
||||
{
|
||||
get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; }
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.1.6.8")]
|
||||
[assembly: AssemblyFileVersion ("1.1.6.8")]
|
||||
[assembly: AssemblyVersion ("1.1.7.89")]
|
||||
[assembly: AssemblyFileVersion ("1.1.7.89")]
|
||||
|
||||
Reference in New Issue
Block a user