Refactor using extensions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using PlantBox.Shared.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -33,7 +34,7 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
{
|
||||
double[] GetArray(string argument)
|
||||
{
|
||||
return argument.Split(ValueSeparator).Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToArray();
|
||||
return argument.Split(ValueSeparator).Select(x => x.ToDouble()).ToArray();
|
||||
}
|
||||
|
||||
if (arguments == null)
|
||||
@@ -45,7 +46,7 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
throw new ArgumentException($"Excepted 4 arguments, got {arguments.Length}");
|
||||
}
|
||||
|
||||
Time = TimeSpan.FromMinutes(double.Parse(arguments[0]));
|
||||
Time = TimeSpan.FromMinutes(arguments[0].ToDouble());
|
||||
Humidities = GetArray(arguments[1]);
|
||||
Luminosities = GetArray(arguments[2]);
|
||||
Temperatures = GetArray(arguments[3]);
|
||||
@@ -62,7 +63,7 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
|
||||
return new[]
|
||||
{
|
||||
Time.TotalMinutes.ToString(CultureInfo.InvariantCulture),
|
||||
Time.TotalMinutes.ToArgument(),
|
||||
Join(Humidities),
|
||||
Join(Luminosities),
|
||||
Join(Temperatures)
|
||||
|
||||
Reference in New Issue
Block a user