Added detector info

This commit is contained in:
2020-12-10 21:18:15 -07:00
parent 3fee402da1
commit 2c5f0b73b9
12 changed files with 112 additions and 34 deletions

View File

@@ -9,4 +9,10 @@
<PackageReference Include="DryIoc.dll" Version="4.5.2" />
</ItemGroup>
<ItemGroup>
<None Update="VehicleConfiguration.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,3 +1,4 @@
using System.Text.Json;
using System.Threading;
using ConsoleApp.Maps;
using DryIoc;
@@ -10,6 +11,8 @@ namespace ConsoleApp
{
container.Register<IMapFactory, MapFactory>(Reuse.Singleton);
container.Register<ISimRunner, SimRunner>(Reuse.Singleton);
container.Register<IVehicle, Vehicle>(Reuse.Singleton);
container.Register<IJsonDeserializor, JsonDeserializor>(Reuse.Singleton);
}

View File

@@ -1,4 +1,7 @@
$HEADER$namespace $NAMESPACE$
namespace ConsoleApp
{
public interface $INTERFACE$ {$END$}
public interface IJsonDeserializor
{
T DeserializeObject<T>(string filePath);
}
}

View File

@@ -1,4 +1,9 @@
$HEADER$namespace $NAMESPACE$
namespace ConsoleApp
{
public interface $INTERFACE$ {$END$}
public interface IVehicle
{
int Length { get; }
int Width { get; }
int DetectorWidth { get; }
}
}

View File

@@ -1,4 +1,15 @@
$HEADER$namespace $NAMESPACE$
using System;
using System.IO;
using System.Text.Json;
namespace ConsoleApp
{
public class $CLASS$ {$END$}
public class JsonDeserializor : IJsonDeserializor
{
public T DeserializeObject<T>(string filePath)
{
var jString = File.ReadAllText(filePath);
return JsonSerializer.Deserialize<T>(jString);
}
}
}

View File

@@ -6,7 +6,7 @@ namespace ConsoleApp
{
private IMapFactory _mapFactory;
public SimRunner(IMapFactory mapFactory)
public SimRunner(IMapFactory mapFactory, IVehicle vehicle)
{
_mapFactory = mapFactory;
}

View File

@@ -1,4 +1,24 @@
$HEADER$namespace $NAMESPACE$
using System;
namespace ConsoleApp
{
public class $CLASS$ {$END$}
public class Vehicle : IVehicle
{
public int Length { get; }
public int Width { get; }
public int DetectorOffset { get;}
public int DetectorWidth { get;}
public Vehicle(IJsonDeserializor jsonDeserializor)
{
var config = jsonDeserializor.DeserializeObject<VehicleConfiguration>("/Users/brady.bodily/Documents/Repositories/CS5890_Robot_Intelligence/RobotIntelFinal/ConsoleApp/VehicleConfiguration.json");
Length = config.Length;
Width = config.Width;
DetectorWidth = config.DetectorWidth;
DetectorOffset = config.DetectorOffset;
}
}
}

View File

@@ -1,4 +1,10 @@
$HEADER$namespace $NAMESPACE$
namespace ConsoleApp
{
public class $CLASS$ {$END$}
public class VehicleConfiguration
{
public int Length { get; set; }
public int Width { get; set; }
public int DetectorWidth { get; set; }
public int DetectorOffset { get; set; }
}
}

View File

@@ -1,3 +1,6 @@
{
"Length": 3,
"Width": 2,
"DetectorWidth": 3,
"DetectorOffset": 1
}