Rename ConditionExpression => VariableExpression

This commit is contained in:
atlimit8
2017-04-11 01:26:38 -05:00
parent 1fa8286f1e
commit e73d3922dd
8 changed files with 18 additions and 18 deletions

View File

@@ -398,13 +398,13 @@ namespace OpenRA
return InvalidValueAction(value, fieldType, fieldName); return InvalidValueAction(value, fieldType, fieldName);
} }
else if (fieldType == typeof(ConditionExpression)) else if (fieldType == typeof(VariableExpression))
{ {
if (value != null) if (value != null)
{ {
try try
{ {
return new ConditionExpression(value); return new VariableExpression(value);
} }
catch (InvalidDataException e) catch (InvalidDataException e)
{ {

View File

@@ -260,7 +260,7 @@
<Compile Include="Primitives\float3.cs" /> <Compile Include="Primitives\float3.cs" />
<Compile Include="InstalledMods.cs" /> <Compile Include="InstalledMods.cs" />
<Compile Include="CryptoUtil.cs" /> <Compile Include="CryptoUtil.cs" />
<Compile Include="Support\ConditionExpression.cs" /> <Compile Include="Support\VariableExpression.cs" />
<Compile Include="ExternalMods.cs" /> <Compile Include="ExternalMods.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -18,7 +18,7 @@ using Expressions = System.Linq.Expressions;
namespace OpenRA.Support namespace OpenRA.Support
{ {
public class ConditionExpression public class VariableExpression
{ {
public readonly string Expression; public readonly string Expression;
readonly HashSet<string> variables = new HashSet<string>(); readonly HashSet<string> variables = new HashSet<string>();
@@ -525,7 +525,7 @@ namespace OpenRA.Support
} }
} }
public ConditionExpression(string expression) public VariableExpression(string expression)
{ {
Expression = expression; Expression = expression;
var tokens = new List<Token>(); var tokens = new List<Token>();

View File

@@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Lint
if (typeof(IEnumerable<string>).IsAssignableFrom(type)) if (typeof(IEnumerable<string>).IsAssignableFrom(type))
return fieldInfo.GetValue(ruleInfo) as IEnumerable<string>; return fieldInfo.GetValue(ruleInfo) as IEnumerable<string>;
if (type == typeof(ConditionExpression)) if (type == typeof(VariableExpression))
{ {
var expr = (ConditionExpression)fieldInfo.GetValue(ruleInfo); var expr = (VariableExpression)fieldInfo.GetValue(ruleInfo);
return expr != null ? expr.Variables : Enumerable.Empty<string>(); return expr != null ? expr.Variables : Enumerable.Empty<string>();
} }
@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Lint
if (typeof(IEnumerable).IsAssignableFrom(type)) if (typeof(IEnumerable).IsAssignableFrom(type))
return (IEnumerable<string>)propertyInfo.GetValue(ruleInfo); return (IEnumerable<string>)propertyInfo.GetValue(ruleInfo);
if (type == typeof(ConditionExpression)) if (type == typeof(VariableExpression))
{ {
var expr = (ConditionExpression)propertyInfo.GetValue(ruleInfo); var expr = (VariableExpression)propertyInfo.GetValue(ruleInfo);
return expr != null ? expr.Variables : Enumerable.Empty<string>(); return expr != null ? expr.Variables : Enumerable.Empty<string>();
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
[ConsumedConditionReference] [ConsumedConditionReference]
[Desc("Boolean expression defining the condition to enable this trait.")] [Desc("Boolean expression defining the condition to enable this trait.")]
public readonly ConditionExpression RequiresCondition = null; public readonly VariableExpression RequiresCondition = null;
public abstract object Create(ActorInitializer init); public abstract object Create(ActorInitializer init);

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Requirements for accepting a plug type.", [Desc("Requirements for accepting a plug type.",
"Key is the plug type that the requirements applies to.", "Key is the plug type that the requirements applies to.",
"Value is the condition expression defining the requirements to place the plug.")] "Value is the condition expression defining the requirements to place the plug.")]
public readonly Dictionary<string, ConditionExpression> Requirements = new Dictionary<string, ConditionExpression>(); public readonly Dictionary<string, VariableExpression> Requirements = new Dictionary<string, VariableExpression>();
[GrantedConditionReference] [GrantedConditionReference]
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } } public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }

View File

@@ -19,7 +19,7 @@ using OpenRA.Support;
namespace OpenRA.Test namespace OpenRA.Test
{ {
[TestFixture] [TestFixture]
public class ConditionExpressionTest public class VariableExpressionTest
{ {
IReadOnlyDictionary<string, int> testValues = new ReadOnlyDictionary<string, int>(new Dictionary<string, int>() IReadOnlyDictionary<string, int> testValues = new ReadOnlyDictionary<string, int>(new Dictionary<string, int>()
{ {
@@ -29,28 +29,28 @@ namespace OpenRA.Test
void AssertFalse(string expression) void AssertFalse(string expression)
{ {
Assert.False(new ConditionExpression(expression).Evaluate(testValues) > 0, expression); Assert.False(new VariableExpression(expression).Evaluate(testValues) > 0, expression);
} }
void AssertTrue(string expression) void AssertTrue(string expression)
{ {
Assert.True(new ConditionExpression(expression).Evaluate(testValues) > 0, expression); Assert.True(new VariableExpression(expression).Evaluate(testValues) > 0, expression);
} }
void AssertValue(string expression, int value) void AssertValue(string expression, int value)
{ {
Assert.AreEqual(value, new ConditionExpression(expression).Evaluate(testValues), expression); Assert.AreEqual(value, new VariableExpression(expression).Evaluate(testValues), expression);
} }
void AssertParseFailure(string expression) void AssertParseFailure(string expression)
{ {
Assert.Throws(typeof(InvalidDataException), () => new ConditionExpression(expression).Evaluate(testValues), expression); Assert.Throws(typeof(InvalidDataException), () => new VariableExpression(expression).Evaluate(testValues), expression);
} }
void AssertParseFailure(string expression, string errorMessage) void AssertParseFailure(string expression, string errorMessage)
{ {
var actualErrorMessage = Assert.Throws(typeof(InvalidDataException), var actualErrorMessage = Assert.Throws(typeof(InvalidDataException),
() => new ConditionExpression(expression).Evaluate(testValues), () => new VariableExpression(expression).Evaluate(testValues),
expression).Message; expression).Message;
Assert.AreEqual(errorMessage, actualErrorMessage, expression + " ===> " + actualErrorMessage); Assert.AreEqual(errorMessage, actualErrorMessage, expression + " ===> " + actualErrorMessage);
} }

View File

@@ -55,7 +55,7 @@
<Compile Include="OpenRA.Mods.Common\ShapeTest.cs" /> <Compile Include="OpenRA.Mods.Common\ShapeTest.cs" />
<Compile Include="OpenRA.Game\OrderTest.cs" /> <Compile Include="OpenRA.Game\OrderTest.cs" />
<Compile Include="OpenRA.Game\PlatformTest.cs" /> <Compile Include="OpenRA.Game\PlatformTest.cs" />
<Compile Include="OpenRA.Game\ConditionExpressionTest.cs" /> <Compile Include="OpenRA.Game\VariableExpressionTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj"> <ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">