refactoring.

(ArchiveFormat): added Query<ResourceOptions> protected method for
convenient invocation of  parameters requests.
(FormatCatalog): changed misguiding method name 'LookupTag' to
'LookupExtension'.
This commit is contained in:
morkt
2014-08-02 10:01:06 +04:00
parent 16efe95597
commit 1b46da45a6
6 changed files with 22 additions and 41 deletions

View File

@@ -294,7 +294,7 @@ namespace GameRes.Formats
uint WriteImageEntry (PackedEntry entry, Stream input, Stream output)
{
var grp = FormatCatalog.Instance.LookupTag<GrpFormat> ("GRP").FirstOrDefault();
var grp = FormatCatalog.Instance.LookupExtension<GrpFormat> ("GRP").FirstOrDefault();
if (null == grp) // probably never happens
throw new FileFormatException ("GRP image encoder not available");
bool is_grp = grp.Signature == FormatCatalog.ReadSignature (input);

View File

@@ -334,15 +334,7 @@ namespace GameRes.Formats
uint? QueryEncryptionInfo ()
{
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.INTNotice,
};
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
var options = GetOptions<IntOptions> (args.Options);
var options = Query<IntOptions> (arcStrings.INTNotice);
return options.EncryptionInfo.GetKey();
}
}

View File

@@ -333,15 +333,7 @@ namespace GameRes.Formats
NpaTitleId QueryGameEncryption ()
{
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.ArcEncryptedNotice,
};
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
var options = GetOptions<NpaOptions> (args.Options);
var options = Query<NpaOptions> (arcStrings.ArcEncryptedNotice);
return options.TitleId;
}

View File

@@ -281,15 +281,8 @@ NextEntry:
ICrypt QueryCryptAlgorithm ()
{
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.ArcEncryptedNotice,
};
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
return GetOptions<Xp3Options> (args.Options).Scheme;
var options = Query<Xp3Options> (arcStrings.ArcEncryptedNotice);
return options.Scheme;
}
public static ICrypt GetScheme (string scheme)

View File

@@ -104,14 +104,8 @@ namespace GameRes.Formats
uint QueryEncryptionKey ()
{
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.YPFNotice,
};
FormatCatalog.Instance.InvokeParametersRequest (this, args);
if (!args.InputResult)
throw new OperationCanceledException();
return GetOptions<YpfOptions> (args.Options).Key;
var options = Query<YpfOptions> (arcStrings.YPFNotice);
return options.Key;
}
private class Parser