Private
Public Access
Added new entries to ValueFactory
This commit is contained in:
1 parent
5663aca3ea
commit
0711fcad67
1 file changed
+22
-4
+22
-4
@@ -2,14 +2,16 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Value {
|
namespace Advanced_Software_Engineering.Verbs.Value {
|
||||||
class ValueFactory {
|
|
||||||
|
public class ValueFactory {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a constant Value to be used later during execution
|
/// Creates a constant Value to be used later during execution
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Text representation of the value</param>
|
/// <param name="value">Text representation of the value</param>
|
||||||
/// <param name="type">What type the value should be</param>
|
/// <param name="type">What type the value should be</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IValue CreateValue(string value, string type) {
|
public static IValue CreateValue(string value, string type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "int":
|
case "int":
|
||||||
return new IntValue(ValueHelper.ConvertToInt(value));
|
return new IntValue(ValueHelper.ConvertToInt(value));
|
||||||
@@ -17,14 +19,30 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
case "double":
|
case "double":
|
||||||
return new DoubleValue(ValueHelper.ConvertToDouble(value));
|
return new DoubleValue(ValueHelper.ConvertToDouble(value));
|
||||||
|
|
||||||
|
case "color":
|
||||||
|
return new ColorValue(ValueHelper.TextToColor(value));
|
||||||
|
|
||||||
|
case "bool":
|
||||||
|
return new BoolValue(ValueHelper.ConvertToBool(value));
|
||||||
|
|
||||||
|
case "expression":
|
||||||
|
return new Exception(ValueHelper.ConvertToExpression(value));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown expected type: " + type.ToString());
|
throw new Exception("Unknown expected type: " + type.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IValue CreateValue(bool b) {
|
||||||
|
return new BoolValue(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IValue CreateValue(double d) {
|
||||||
|
return new DoubleValue(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IValue CreateValue(int i) {
|
||||||
|
return new IntValue(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user