Add constructors for ScoreOperation.
This commit is contained in:
@@ -52,11 +52,7 @@ namespace Cryville.Crtr {
|
|||||||
return new Identifier(exp);
|
return new Identifier(exp);
|
||||||
}
|
}
|
||||||
else if (type == typeof(ScoreOperation)) {
|
else if (type == typeof(ScoreOperation)) {
|
||||||
var m = Regex.Match(exp, @"^(\S+)\s*?(\S+)?$");
|
return new ScoreOperation(exp);
|
||||||
var name = new Identifier(m.Groups[1].Value);
|
|
||||||
if (!m.Groups[2].Success) return new ScoreOperation { name = name };
|
|
||||||
var op = new Identifier(m.Groups[2].Value);
|
|
||||||
return new ScoreOperation { name = name, op = op };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return base.ChangeType(value, type, culture);
|
return base.ChangeType(value, type, culture);
|
||||||
|
|||||||
@@ -91,6 +91,16 @@ namespace Cryville.Crtr {
|
|||||||
public class ScoreOperation {
|
public class ScoreOperation {
|
||||||
public Identifier name;
|
public Identifier name;
|
||||||
public Identifier op;
|
public Identifier op;
|
||||||
|
public ScoreOperation(Identifier name, Identifier op) {
|
||||||
|
this.name = name;
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
public ScoreOperation(string str) {
|
||||||
|
var m = Regex.Match(str, @"^(\S+)\s*?(\S+)?$");
|
||||||
|
name = new Identifier(m.Groups[1].Value);
|
||||||
|
if (!m.Groups[2].Success) return;
|
||||||
|
op = new Identifier(m.Groups[2].Value);
|
||||||
|
}
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
if (op == default(Identifier)) return name.ToString();
|
if (op == default(Identifier)) return name.ToString();
|
||||||
else return string.Format("{0} {1}", name, op);
|
else return string.Format("{0} {1}", name, op);
|
||||||
|
|||||||
Reference in New Issue
Block a user