Skip to content

Commit 39f2689

Browse files
authored
Make usage of expressions in Contract Requirement possible (#36)
An expression in "contractType" would cause a nullReferenceException before this change. Added validation for mutually exclusive "tag" and "contractType".
1 parent b57a94a commit 39f2689

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

source/ContractConfigurator/Requirement/ContractCheckRequirement.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,18 @@ public override bool LoadFromConfig(ConfigNode configNode)
2828
const string nullString = null; // to get around the fact this is overloaded.
2929
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "tag", x => tag = x, this, nullString);
3030

31-
// Get type
32-
string contractType = null;
33-
valid &= tag != null || ConfigNodeUtil.ParseValue<string>(configNode, "contractType", x => contractType = x, this);
34-
3531
// By default, always check the requirement for active contracts
3632
valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "checkOnActiveContract", x => checkOnActiveContract = x, this, true);
3733

38-
if (valid)
39-
{
40-
if (tag == null)
41-
valid &= SetValues(contractType);
42-
else
43-
ccType = null;
44-
}
34+
// Get type
35+
string dummy = null;
36+
valid &= ConfigNodeUtil.ParseValue<string>(configNode, "contractType", x => dummy = x, this, SetValues);
4537

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

41+
valid &= ConfigNodeUtil.MutuallyExclusive(configNode, new string[] { "tag" }, new string[] { "contractType" }, this);
42+
4943
return valid;
5044
}
5145

0 commit comments

Comments
 (0)