Add backward compatibility for skin.
This commit is contained in:
@@ -54,15 +54,14 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="binder">The binder.</param>
|
||||
/// <returns>The interpreted object.</returns>
|
||||
public static T Interpret<T>(string src, Binder binder) {
|
||||
return (T)new PdtInterpreter(src, typeof(T), binder).Interpret();
|
||||
return (T)new PdtInterpreter(src, binder).Interpret(typeof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The source string.
|
||||
/// </summary>
|
||||
public string Source { get; private set; }
|
||||
readonly Type _type;
|
||||
readonly Binder _binder;
|
||||
Binder _binder;
|
||||
/// <summary>
|
||||
/// The current position in the string being parsed by the interpreter.
|
||||
/// </summary>
|
||||
@@ -167,23 +166,27 @@ namespace Cryville.Common.Pdt {
|
||||
/// Creates an instance of the <see cref="PdtInterpreter" /> class.
|
||||
/// </summary>
|
||||
/// <param name="src">The source string.</param>
|
||||
/// <param name="type">The destination type.</param>
|
||||
/// <param name="binder">The binder. May be <c>null</c>.</param>
|
||||
public PdtInterpreter(string src, Type type, Binder binder) {
|
||||
public PdtInterpreter(string src, Binder binder) {
|
||||
Source = src;
|
||||
_type = type;
|
||||
_binder = binder;
|
||||
if (_binder == null)
|
||||
_binder = BinderAttribute.CreateBinderOfType(_type);
|
||||
}
|
||||
int[] m_formatVersion;
|
||||
public int[] GetFormatVersion() {
|
||||
if (m_formatVersion == null) InterpretDirectives();
|
||||
return m_formatVersion;
|
||||
}
|
||||
/// <summary>
|
||||
/// Interprets the source to an object.
|
||||
/// </summary>
|
||||
/// <param name="type">The output type.</param>
|
||||
/// <returns>The interpreted object.</returns>
|
||||
public object Interpret() {
|
||||
public object Interpret(Type type) {
|
||||
try {
|
||||
InterpretDirectives();
|
||||
return InterpretObject(_type);
|
||||
if (m_formatVersion == null) InterpretDirectives();
|
||||
if (_binder == null)
|
||||
_binder = BinderAttribute.CreateBinderOfType(type);
|
||||
return InterpretObject(type);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new PdtParsingException(this, ex);
|
||||
@@ -201,7 +204,10 @@ namespace Cryville.Common.Pdt {
|
||||
break;
|
||||
case "format":
|
||||
ws();
|
||||
if (GetNumber() != "1")
|
||||
m_formatVersion = (from i in GetNumber().Split('.') select int.Parse(i)).ToArray();
|
||||
if (m_formatVersion.Length == 0)
|
||||
throw new FormatException("Invalid format version");
|
||||
if (m_formatVersion[0] != 1)
|
||||
throw new NotSupportedException("Format not supported");
|
||||
flag = true;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user