Skip to content

Commit

Permalink
Make usage of expressions in Contract Requirement possible (#36)
Browse files Browse the repository at this point in the history
An expression in "contractType" would cause a nullReferenceException before this change.
Added validation for mutually exclusive "tag" and "contractType".
  • Loading branch information
IO5 authored Jan 6, 2024
1 parent b57a94a commit 39f2689
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,18 @@ public override bool LoadFromConfig(ConfigNode configNode)
const string nullString = null; // to get around the fact this is overloaded.
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "tag", x => tag = x, this, nullString);

// Get type
string contractType = null;
valid &= tag != null || ConfigNodeUtil.ParseValue<string>(configNode, "contractType", x => contractType = x, this);

// By default, always check the requirement for active contracts
valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "checkOnActiveContract", x => checkOnActiveContract = x, this, true);

if (valid)
{
if (tag == null)
valid &= SetValues(contractType);
else
ccType = null;
}
// Get type
string dummy = null;
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "contractType", x => dummy = x, this, SetValues);

valid &= ConfigNodeUtil.ParseValue<uint>(configNode, "minCount", x => minCount = x, this, 1);
valid &= ConfigNodeUtil.ParseValue<uint>(configNode, "maxCount", x => maxCount = x, this, UInt32.MaxValue);

valid &= ConfigNodeUtil.MutuallyExclusive(configNode, new string[] { "tag" }, new string[] { "contractType" }, this);

return valid;
}

Expand Down

0 comments on commit 39f2689

Please sign in to comment.