Refactor using extensions

This commit is contained in:
2019-03-24 12:14:28 +01:00
parent ed635c5ec2
commit 73855e246c
6 changed files with 71 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
using System;
using PlantBox.Shared.Extensions;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
@@ -26,9 +27,9 @@ namespace PlantBox.Shared.Communication.Commands
}
Name = arguments[0];
Type = (PlantType)Enum.Parse(typeof(PlantType), arguments[1], true);
State = (PlantState)Enum.Parse(typeof(PlantState), arguments[2], true);
Water = double.Parse(arguments[3], CultureInfo.InvariantCulture);
Type = arguments[1].ToEnumValue<PlantType>();
State = arguments[2].ToEnumValue<PlantState>();
Water = arguments[3].ToDouble();
return this;
}
@@ -40,7 +41,7 @@ namespace PlantBox.Shared.Communication.Commands
Name,
Type.ToString(),
State.ToString(),
Water.ToString(CultureInfo.InvariantCulture)
Water.ToArgument()
};
}
}