Framework Setup
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\DryIoc.4.1.4\build\DryIoc.props" Condition="Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{F65ECA33-08FF-4797-8E53-B086320214F4}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>BattleFieldSimulator.Utilities</RootNamespace>
|
||||||
|
<AssemblyName>BattleFieldSimulator.Utilities</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="BootStrapper.cs" />
|
||||||
|
<Compile Include="Class1.cs" />
|
||||||
|
<Compile Include="DryIoc\Container.cs" />
|
||||||
|
<Compile Include="DryIoc\Expression.cs" />
|
||||||
|
<Compile Include="DryIoc\FastExpressionCompiler.cs" />
|
||||||
|
<Compile Include="DryIoc\ImTools.cs" />
|
||||||
|
<Compile Include="IModule.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\DryIoc.4.1.4\build\DryIoc.props'))" />
|
||||||
|
</Target>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator
|
||||||
|
{
|
||||||
|
public class BootStrapper
|
||||||
|
{
|
||||||
|
private static readonly string NoBootstrapperMessage = $"Called {nameof(BootStrapper)} before it existed";
|
||||||
|
|
||||||
|
private static BootStrapper _bootStrapper;
|
||||||
|
private static IContainer _container;
|
||||||
|
|
||||||
|
public static BootStrapper Instance =>
|
||||||
|
_bootStrapper ?? throw new InvalidOperationException(NoBootstrapperMessage);
|
||||||
|
|
||||||
|
private BootStrapper(params IModule[] modules)
|
||||||
|
{
|
||||||
|
_container = new Container();
|
||||||
|
foreach (var module in modules)
|
||||||
|
{
|
||||||
|
module.Register(_container);
|
||||||
|
}
|
||||||
|
foreach (var module in modules)
|
||||||
|
{
|
||||||
|
module.Resolve(_container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BootStrapper BootstrapSystem(params IModule[] modules) =>
|
||||||
|
_bootStrapper = new BootStrapper(modules);
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace BattleFieldSimulator.Utilities
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+4739
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.Utilities
|
||||||
|
{
|
||||||
|
public interface IModule
|
||||||
|
{
|
||||||
|
void Register(IContainer container);
|
||||||
|
void Resolve(IContainer container);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("BattleFieldSimulator.Utilities")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("BattleFieldSimulator.Utilities")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("F65ECA33-08FF-4797-8E53-B086320214F4")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="DryIoc" version="4.1.4" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleFieldSimulator", "BattleFieldSimulator\BattleFieldSimulator.csproj", "{985EC30A-C845-4147-B808-D2FB9309B75E}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{985EC30A-C845-4147-B808-D2FB9309B75E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{985EC30A-C845-4147-B808-D2FB9309B75E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{985EC30A-C845-4147-B808-D2FB9309B75E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{985EC30A-C845-4147-B808-D2FB9309B75E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\DryIoc.4.1.4\build\DryIoc.props" Condition="Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{985EC30A-C845-4147-B808-D2FB9309B75E}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>BattleFieldSimulator</RootNamespace>
|
||||||
|
<AssemblyName>BattleFieldSimulator</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="BattlefieldEnviornment\Map.cs" />
|
||||||
|
<Compile Include="BootStrapper.cs" />
|
||||||
|
<Compile Include="ConsoleClient\ConsoleClient.cs" />
|
||||||
|
<Compile Include="CoreModule.cs" />
|
||||||
|
<Compile Include="DryIoc\Container.cs" />
|
||||||
|
<Compile Include="DryIoc\Expression.cs" />
|
||||||
|
<Compile Include="DryIoc\FastExpressionCompiler.cs" />
|
||||||
|
<Compile Include="DryIoc\ImTools.cs" />
|
||||||
|
<Compile Include="Exceptions\IBattleFieldException.cs" />
|
||||||
|
<Compile Include="Exceptions\ItemNotFoundException.cs" />
|
||||||
|
<Compile Include="FileSystem\FileSystem.cs" />
|
||||||
|
<Compile Include="FileSystem\FileSystemConstants.cs" />
|
||||||
|
<Compile Include="FileSystem\IFileSystem.cs" />
|
||||||
|
<Compile Include="IModule.cs" />
|
||||||
|
<Compile Include="JsonSerialization\IJsonObject.cs" />
|
||||||
|
<Compile Include="JsonSerialization\IJsonSerializer.cs" />
|
||||||
|
<Compile Include="JsonSerialization\JsonObjectWrapper.cs" />
|
||||||
|
<Compile Include="JsonSerialization\JsonSerializer.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SimRunner\ISimRunner.cs" />
|
||||||
|
<Compile Include="SimRunner\SimRunner.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\DryIoc.4.1.4\build\DryIoc.props'))" />
|
||||||
|
</Target>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using BattleFieldSimulator.JsonSerialization;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.BattlefieldEnviornment
|
||||||
|
{
|
||||||
|
public class Map
|
||||||
|
{
|
||||||
|
public List<List<int>> Grid { get; }
|
||||||
|
public int X { get; }
|
||||||
|
public int Y { get; }
|
||||||
|
public Map(int x, int y, IEnumerable<IJsonObject> grid)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
Grid = ConvertGrid(grid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<int>> ConvertGrid(IEnumerable<IJsonObject> grid)
|
||||||
|
{
|
||||||
|
var r_grid = new List<List<int>>();
|
||||||
|
var index = 0;
|
||||||
|
var jsonObjects = grid.ToList();
|
||||||
|
for (var i = 0; i < X; i++)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < Y; j++)
|
||||||
|
{
|
||||||
|
r_grid[i][j] = int.Parse(jsonObjects[index].ToString());
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r_grid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator
|
||||||
|
{
|
||||||
|
public class BootStrapper
|
||||||
|
{
|
||||||
|
private static readonly string NoBootstrapperMessage = $"Called {nameof(BootStrapper)} before it existed";
|
||||||
|
|
||||||
|
private static BootStrapper _bootStrapper;
|
||||||
|
private static IContainer _container;
|
||||||
|
|
||||||
|
public static BootStrapper Instance =>
|
||||||
|
_bootStrapper ?? throw new InvalidOperationException(NoBootstrapperMessage);
|
||||||
|
|
||||||
|
private BootStrapper(params IModule[] modules)
|
||||||
|
{
|
||||||
|
_container = new Container();
|
||||||
|
foreach (var module in modules)
|
||||||
|
{
|
||||||
|
module.Register(_container);
|
||||||
|
}
|
||||||
|
foreach (var module in modules)
|
||||||
|
{
|
||||||
|
module.Resolve(_container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BootStrapper BootstrapSystem(params IModule[] modules) =>
|
||||||
|
_bootStrapper = new BootStrapper(modules);
|
||||||
|
|
||||||
|
public T Resolve<T>() => _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using BattleFieldSimulator.SimRunner;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.ConsoleClient
|
||||||
|
{
|
||||||
|
public class ConsoleClient
|
||||||
|
{
|
||||||
|
private ISimRunner _simRunner;
|
||||||
|
|
||||||
|
public ConsoleClient(ISimRunner simRunner)
|
||||||
|
{
|
||||||
|
_simRunner = simRunner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run(string[] args)
|
||||||
|
{
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
var inputValid = false;
|
||||||
|
var input = "";
|
||||||
|
while (!inputValid)
|
||||||
|
{
|
||||||
|
DisplayWelcome();
|
||||||
|
input = Console.ReadLine();
|
||||||
|
inputValid = ValidInput(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (input)
|
||||||
|
{
|
||||||
|
case "-h":
|
||||||
|
PrintHelpMenu();
|
||||||
|
break;
|
||||||
|
case "-r":
|
||||||
|
_simRunner.RunSimulation();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrintHelpMenu()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ValidInput(string input) => input == "-h" || input == "-r" || input == "-q";
|
||||||
|
|
||||||
|
private void DisplayWelcome()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Welcome to the battlefield simulator! \n \n " +
|
||||||
|
"Please make a selection: \n" +
|
||||||
|
"\t <-h> help menu \n" +
|
||||||
|
"\t <-r> run program \n" +
|
||||||
|
"\t <-q> exit program \n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using BattleFieldSimulator.SimRunner;
|
||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator
|
||||||
|
{
|
||||||
|
public class CoreModule : IModule
|
||||||
|
{
|
||||||
|
public void Register(IContainer container)
|
||||||
|
{
|
||||||
|
container.Register<ISimRunner, SimRunner.SimRunner>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resolve(IContainer container)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.Exceptions
|
||||||
|
{
|
||||||
|
public abstract class BattleFieldException : Exception
|
||||||
|
{
|
||||||
|
public abstract string Explanation { get; }
|
||||||
|
|
||||||
|
protected BattleFieldException(string message) : base((string.IsNullOrWhiteSpace(message)
|
||||||
|
? throw new ArgumentException("You must provide a message that is not null or whitespace.", nameof(message))
|
||||||
|
: message)){}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace BattleFieldSimulator.Exceptions
|
||||||
|
{
|
||||||
|
public class ItemNotFoundException : BattleFieldException
|
||||||
|
{
|
||||||
|
public ItemNotFoundException(string message) : base(message)
|
||||||
|
{
|
||||||
|
Explanation = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Explanation { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.FileSystem
|
||||||
|
{
|
||||||
|
public class FileSystem : IFileSystem
|
||||||
|
{
|
||||||
|
public FileSystem()
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(FileSystemConstants.LogDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void WriteTextToFile(string filePath, string message)
|
||||||
|
{
|
||||||
|
var directoryPath = Path.GetDirectoryName(filePath);
|
||||||
|
if (!DirectoryExists(directoryPath))
|
||||||
|
CreateDirectory(directoryPath);
|
||||||
|
File.WriteAllText(filePath, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void AppendTextToFile(string filePath, string message)
|
||||||
|
{
|
||||||
|
var directoryPath = Path.GetDirectoryName(filePath);
|
||||||
|
if (!DirectoryExists(directoryPath))
|
||||||
|
CreateDirectory(directoryPath);
|
||||||
|
File.AppendAllText(filePath, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool FileExists(string filePath)
|
||||||
|
{
|
||||||
|
return File.Exists(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void RenameFile(string originalFilePath, string newName)
|
||||||
|
{
|
||||||
|
File.Move(originalFilePath, FormPath(Path.GetDirectoryName(originalFilePath), newName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool DirectoryExists(string directoryPath)
|
||||||
|
{
|
||||||
|
return Directory.Exists(directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void DeleteFile(string filePath)
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void CreateFile(string filePath, MemoryStream memoryStream)
|
||||||
|
{
|
||||||
|
var file = new FileStream($"{filePath}temp",
|
||||||
|
FileMode.Create, FileAccess.Write);
|
||||||
|
memoryStream.WriteTo(file);
|
||||||
|
file.Close();
|
||||||
|
File.Move($"{filePath}temp",
|
||||||
|
filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void CopyDirectoryContents(string sourceDirectoryPath, string destinationDirectoryPath)
|
||||||
|
{
|
||||||
|
var sourceDirectory = new DirectoryInfo(sourceDirectoryPath);
|
||||||
|
|
||||||
|
if (!sourceDirectory.Exists)
|
||||||
|
throw new DirectoryNotFoundException(
|
||||||
|
$"Source directory does not exist or could not be found: {sourceDirectoryPath}");
|
||||||
|
|
||||||
|
var sourceSubdirectories = sourceDirectory.GetDirectories();
|
||||||
|
|
||||||
|
if (!Directory.Exists(destinationDirectoryPath))
|
||||||
|
Directory.CreateDirectory(destinationDirectoryPath);
|
||||||
|
|
||||||
|
var sourceDirectoryFiles = sourceDirectory.GetFiles();
|
||||||
|
|
||||||
|
foreach (var file in sourceDirectoryFiles)
|
||||||
|
{
|
||||||
|
var tempPath = FormPath(destinationDirectoryPath, file.Name);
|
||||||
|
file.CopyTo(tempPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var subdirectory in sourceSubdirectories)
|
||||||
|
{
|
||||||
|
var tempPath = FormPath(destinationDirectoryPath, subdirectory.Name);
|
||||||
|
CopyDirectoryContents(subdirectory.FullName, tempPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string ReadAllText(string filePath)
|
||||||
|
{
|
||||||
|
return File.ReadAllText(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IEnumerable<string> GetFiles(string directoryPath, string searchPattern, SearchOption searchOption) =>
|
||||||
|
DirectoryExists(directoryPath)
|
||||||
|
? Directory.GetFiles(directoryPath, searchPattern, searchOption)
|
||||||
|
: new string[0];
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public byte[] ReadAllBytes(string filePath)
|
||||||
|
{
|
||||||
|
return File.ReadAllBytes(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void CreateDirectory(string directoryPath)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void DeleteDirectoryContents(string directoryPath)
|
||||||
|
{
|
||||||
|
if (!DirectoryExists(directoryPath))
|
||||||
|
return;
|
||||||
|
var directory = new DirectoryInfo(directoryPath);
|
||||||
|
foreach (var file in directory.GetFiles()) file.Delete();
|
||||||
|
foreach (var dir in directory.GetDirectories()) dir.Delete(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string GetFileName(string filePath)
|
||||||
|
{
|
||||||
|
return Path.GetFileName(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string GetDirectoryName(string directoryPath)
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void CopyFile(string originalFilePath, string targetFilePath) =>
|
||||||
|
File.Copy(originalFilePath, targetFilePath, true);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string FormPath(params string[] pathParts) => Path.Combine(pathParts);
|
||||||
|
|
||||||
|
public string GetUserTempDirectory() => Path.GetTempPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using static System.IO.Path;
|
||||||
|
using static System.Environment.SpecialFolder;
|
||||||
|
using static System.Environment;
|
||||||
|
namespace BattleFieldSimulator.FileSystem
|
||||||
|
{
|
||||||
|
public static class FileSystemConstants
|
||||||
|
{
|
||||||
|
public static readonly string LogDirectory =
|
||||||
|
Combine(GetFolderPath(CommonDocuments), "BattlefieldSimulator", "Logs");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.FileSystem
|
||||||
|
{
|
||||||
|
public interface IFileSystem
|
||||||
|
{
|
||||||
|
#region File Operations
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
void WriteTextToFile(string filePath, string message);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
void AppendTextToFile(string filePath, string message);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the specified file exists.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool FileExists(string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the file at the given path. Nothing happens if the target file doesn't exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
void DeleteFile(string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new file at <see cref="filePath"/> and writes the <see cref="MemoryStream"/> to that file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <param name="memoryStream"></param>
|
||||||
|
void CreateFile(string filePath, MemoryStream memoryStream);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads file at <see cref="filePath"/> and returns all contents as a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string ReadAllText(string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
/// <param name="searchPattern"></param>
|
||||||
|
/// <param name="searchOption"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerable<string> GetFiles(string directoryPath, string searchPattern, SearchOption searchOption);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
byte[] ReadAllBytes(string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all files in the specified directory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
void DeleteDirectoryContents(string directoryPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies from the given original path to the given target path, overwriting the file in the target location, if necessary.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalFilePath"></param>
|
||||||
|
/// <param name="targetFilePath"></param>
|
||||||
|
void CopyFile(string originalFilePath, string targetFilePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renames the file at <see cref="originalFilePath"/> to <see cref="newName"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalFilePath"></param>
|
||||||
|
/// <param name="newName"></param>
|
||||||
|
void RenameFile(string originalFilePath, string newName);
|
||||||
|
|
||||||
|
#endregion File Operations
|
||||||
|
|
||||||
|
#region Directory Operations
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the given path refers to an existing directory on disk.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool DirectoryExists(string directoryPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates all directories and subdirectories in the specified path unless they already exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
void CreateDirectory(string directoryPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies a directory at <see cref="sourceFilePath"/> and all its contents to <see cref="destinationFilePath"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceFilePath"></param>
|
||||||
|
/// <param name="destinationFilePath"></param>
|
||||||
|
void CopyDirectoryContents(string sourceFilePath, string destinationFilePath);
|
||||||
|
|
||||||
|
#endregion Directory Operations
|
||||||
|
|
||||||
|
#region Path Operations
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the file name and extension of the specified path string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetFileName(string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the directory information for the specified path string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetDirectoryName(string directoryPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Combines an array of strings into a path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParts"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string FormPath(params string[] pathParts);
|
||||||
|
|
||||||
|
string GetUserTempDirectory();
|
||||||
|
|
||||||
|
#endregion Path Operations
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator
|
||||||
|
{
|
||||||
|
public interface IModule
|
||||||
|
{
|
||||||
|
void Register(IContainer container);
|
||||||
|
void Resolve(IContainer container);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace BattleFieldSimulator.JsonSerialization
|
||||||
|
{
|
||||||
|
public interface IJsonObject
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace BattleFieldSimulator.JsonSerialization
|
||||||
|
{
|
||||||
|
public interface IJsonSerializer
|
||||||
|
{
|
||||||
|
T Deserialize<T>(string serialized);
|
||||||
|
IJsonObject Deserialize(string filepath);
|
||||||
|
string Serialize(object obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using BattleFieldSimulator.BattlefieldEnviornment;
|
||||||
|
using BattleFieldSimulator.Exceptions;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.JsonSerialization
|
||||||
|
{
|
||||||
|
public class JsonObjectWrapper : IJsonObject
|
||||||
|
{
|
||||||
|
private readonly JObject _jObject;
|
||||||
|
|
||||||
|
public JsonObjectWrapper(JObject jObject)
|
||||||
|
{
|
||||||
|
_jObject = jObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IJsonObject> GetJsonArray(string dataIdentifier)
|
||||||
|
{
|
||||||
|
return GetData<JToken,IEnumerable<IJsonObject>> (dataIdentifier, ConvertJsonArray);
|
||||||
|
|
||||||
|
IEnumerable<JsonObjectWrapper> ConvertJsonArray(JToken jArray)
|
||||||
|
{
|
||||||
|
foreach (var token in jArray)
|
||||||
|
{
|
||||||
|
foreach (var item in token)
|
||||||
|
{
|
||||||
|
yield return new JsonObjectWrapper(item as JObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map GetMap(string dataIdentifier) => GetData<JToken, Map>(dataIdentifier, jArray =>
|
||||||
|
{
|
||||||
|
if (!jArray.Any())
|
||||||
|
return (Map) null;
|
||||||
|
var x = jArray["X"].Value<int>();
|
||||||
|
var y = jArray["Y"].Value<int>();
|
||||||
|
var grid = GetJsonArray("map");
|
||||||
|
return new Map(x, y, grid);
|
||||||
|
});
|
||||||
|
|
||||||
|
private T2 GetData<T1, T2>(string dataIdentifier, Func<T1, T2> convertFunc)
|
||||||
|
{
|
||||||
|
if (_jObject.ContainsKey(dataIdentifier))
|
||||||
|
return convertFunc.Invoke(_jObject[dataIdentifier].Value<T1>());
|
||||||
|
throw new ItemNotFoundException($"Data Identifier \"{dataIdentifier}\" was not found in the file.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using BattleFieldSimulator.FileSystem;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator.JsonSerialization
|
||||||
|
{
|
||||||
|
public class JsonSerializer : IJsonSerializer
|
||||||
|
{
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
|
public JsonSerializer(IFileSystem fileSystem) => _fileSystem = fileSystem;
|
||||||
|
|
||||||
|
public T Deserialize<T>(string serialized) => JsonConvert.DeserializeObject<T>(serialized);
|
||||||
|
|
||||||
|
public IJsonObject Deserialize(string filepath) =>
|
||||||
|
new JsonObjectWrapper(JObject.Parse(_fileSystem.ReadAllText(filepath)));
|
||||||
|
|
||||||
|
public string Serialize(object obj) => JsonConvert.SerializeObject(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using BattleFieldSimulator.SimRunner;
|
||||||
|
|
||||||
|
namespace BattleFieldSimulator
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
|
||||||
|
var simRunner = bootstrapper.Resolve<ISimRunner>();
|
||||||
|
var consoleClient = new ConsoleClient.ConsoleClient(simRunner);
|
||||||
|
consoleClient.Run(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("BattleFieldSimulator")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("BattleFieldSimulator")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("985EC30A-C845-4147-B808-D2FB9309B75E")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace BattleFieldSimulator.SimRunner
|
||||||
|
{
|
||||||
|
public interface ISimRunner
|
||||||
|
{
|
||||||
|
void RunSimulation();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace BattleFieldSimulator.SimRunner
|
||||||
|
{
|
||||||
|
public class SimRunner : ISimRunner
|
||||||
|
{
|
||||||
|
public SimRunner()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunSimulation()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Debug/BattleFieldSimulator.csprojAssemblyReference.cache
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Debug/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Debug/BattleFieldSimulator.pdb
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Debug/BattleFieldSimulator.exe
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Debug/BattleFieldSimulator.pdb
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Debug/Newtonsoft.Json.dll
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/bin/Debug/Newtonsoft.Json.xml
|
||||||
|
/Users/bradybodily/Repositories/CS5110_Multi_Agent/BattleFieldSimulator/BattleFieldSimulator/obj/Debug/BattleFieldSimulator.csproj.CopyComplete
|
||||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="DryIoc" version="4.1.4" targetFramework="net472" />
|
||||||
|
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\DryIoc.4.1.4\build\DryIoc.props" Condition="Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{35646D97-C2E5-4869-8995-2CB075E0631F}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ConsoleClient</RootNamespace>
|
||||||
|
<AssemblyName>ConsoleClient</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ConsoleClientModule.cs" />
|
||||||
|
<Compile Include="DryIoc\Container.cs" />
|
||||||
|
<Compile Include="DryIoc\Expression.cs" />
|
||||||
|
<Compile Include="DryIoc\FastExpressionCompiler.cs" />
|
||||||
|
<Compile Include="DryIoc\ImTools.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\DryIoc.4.1.4\build\DryIoc.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\DryIoc.4.1.4\build\DryIoc.props'))" />
|
||||||
|
</Target>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using DryIoc;
|
||||||
|
|
||||||
|
namespace ConsoleClient
|
||||||
|
{
|
||||||
|
public class ConsoleClientModule
|
||||||
|
{
|
||||||
|
public class CoreModule : IModule
|
||||||
|
{
|
||||||
|
public void Register(IContainer container)
|
||||||
|
{
|
||||||
|
container.Register<ISimRunner, SimRunner.SimRunner>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resolve(IContainer container)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
namespace ConsoleClient
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ConsoleClient")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ConsoleClient")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("35646D97-C2E5-4869-8995-2CB075E0631F")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="DryIoc" version="4.1.4" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
BIN
Binary file not shown.
Vendored
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma warning disable 1591
|
||||||
|
|
||||||
|
namespace Example
|
||||||
|
{
|
||||||
|
public interface IService { }
|
||||||
|
|
||||||
|
public class MyService : IService
|
||||||
|
{
|
||||||
|
public MyService(IDependencyA a, DependencyB<string> b, RuntimeDependencyC c) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IDependencyA { }
|
||||||
|
|
||||||
|
public class DependencyA : IDependencyA { }
|
||||||
|
|
||||||
|
public class DependencyB<T>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RuntimeDependencyC
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
Executable
+58
@@ -0,0 +1,58 @@
|
|||||||
|
<#
|
||||||
|
// TODO:
|
||||||
|
// 1. Fill-in method `GetContainerWithRegistrations` below with creation of DryIoc `Container` and registrations.
|
||||||
|
// 2. Specify the resolution roots via `SpecifyResolutionRoots` method, see example below.
|
||||||
|
// 3. Save the "Container.Generated.tt" file. Confirm the Visual Studio prompt if any.
|
||||||
|
// 4. Check the "Container.Generated.cs" for the generated results and issues.
|
||||||
|
//
|
||||||
|
// Note:
|
||||||
|
// - When specifying assembly path, you may use $(SolutionDir), $(ProjectDir), $(Configuration) parameters.
|
||||||
|
//
|
||||||
|
#>
|
||||||
|
<#@ import Namespace="DryIoc" #>
|
||||||
|
<#@ import Namespace="ImTools" #>
|
||||||
|
<#// TODO: Insert the assemblies and namespaces of your services to be registered in container #>
|
||||||
|
<#@ import Namespace="Example" #>
|
||||||
|
<#+
|
||||||
|
// TODO: Specify the container and registrations ...
|
||||||
|
IContainer GetContainerWithRegistrations()
|
||||||
|
{
|
||||||
|
var container = new Container();
|
||||||
|
|
||||||
|
// NOTE: `RegisterDelegate`, `RegisterInstance` and `Use` methods are not supported because of runtime state usage.
|
||||||
|
// Instead you can use `RegisterPlaceholder` to put a hole in the generated object graph, then you fill it in with the runtime registration.
|
||||||
|
|
||||||
|
// TODO: Add the registrations to generate factories for them in compile-time...
|
||||||
|
// for example:
|
||||||
|
container.Register<IService, MyService>();
|
||||||
|
container.Register<IDependencyA, DependencyA>();
|
||||||
|
container.Register(typeof(DependencyB<>));
|
||||||
|
container.RegisterPlaceholder<RuntimeDependencyC>();
|
||||||
|
|
||||||
|
// or from the assembly:
|
||||||
|
// container.RegisterMany(new[] { MyAssembly });
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: For each passed registration specify what resolution roots it provides, null if none
|
||||||
|
ServiceInfo[] SpecifyResolutionRoots(ServiceRegistrationInfo reg)
|
||||||
|
{
|
||||||
|
return reg.AsResolutionRoot ? reg.ToServiceInfo().One() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Explicitly specified roots to generate ...
|
||||||
|
ServiceInfo[] CustomResolutionRoots =
|
||||||
|
{
|
||||||
|
// for example:
|
||||||
|
ServiceInfo.Of<Example.IService>(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Specify the namespace to go into `using` instead of qualify the type all the times,
|
||||||
|
// You may generate the Container.Generated.cs first, then look what you want to move to using
|
||||||
|
string[] NamespaceUsings =
|
||||||
|
{
|
||||||
|
"Example",
|
||||||
|
//"Foo.Bar.Buzz",
|
||||||
|
};
|
||||||
|
#>
|
||||||
+281
@@ -0,0 +1,281 @@
|
|||||||
|
// <auto-generated/>
|
||||||
|
#if !PCL && !NETSTANDARD1_0 && !NETSTANDARD1_1 && !NETSTANDARD1_2 && !NETSTANDARD1_3 && !NETSTANDARD1_4 && !NETSTANDARD1_5
|
||||||
|
/*
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016-2020 Maksim Volkau
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
<#@ template debug="false" hostspecific="true" language="C#" #>
|
||||||
|
<#@ output extension=".cs" #>
|
||||||
|
<#@ CleanupBehavior processor="T4VSHost" CleanupAfterProcessingtemplate="true" #>
|
||||||
|
<#@ assembly Name="System.Core" #>
|
||||||
|
<#@ assembly Name="System.Runtime" #>
|
||||||
|
<#@ assembly Name="$(ExpressionToCodeLibAssembly)" #>
|
||||||
|
<#@ assembly Name="$(TargetPath)" #>
|
||||||
|
<#@ import Namespace="ExpressionToCodeLib" #>
|
||||||
|
<#@ import Namespace="System.Linq" #>
|
||||||
|
<#@ import Namespace="System.Linq.Expressions" #>
|
||||||
|
<#@ import Namespace="DryIoc" #>
|
||||||
|
<#@ import Namespace="ImTools" #>
|
||||||
|
<#@ include File="CompileTimeRegistrations.ttinclude" #>
|
||||||
|
<#
|
||||||
|
var container = GetContainerWithRegistrations().With(rules => rules.ForExpressionGeneration());
|
||||||
|
|
||||||
|
var includeVariants = container.Rules.VariantGenericTypesInResolvedCollection;
|
||||||
|
|
||||||
|
var result = container.GenerateResolutionExpressions(x => x.SelectMany(r =>
|
||||||
|
SpecifyResolutionRoots(r).EmptyIfNull()).Concat(CustomResolutionRoots.EmptyIfNull()));
|
||||||
|
|
||||||
|
var exprToCode = ExpressionToCodeConfiguration.DefaultCodeGenConfiguration
|
||||||
|
.WithObjectStringifier(ObjectStringify.WithFullTypeNames);
|
||||||
|
|
||||||
|
string RemoveUsings(string source)
|
||||||
|
{
|
||||||
|
foreach (var x in NamespaceUsings)
|
||||||
|
source = source.Replace(x + ".", "");
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Code(object x) =>
|
||||||
|
x == null ? "null" :
|
||||||
|
x is Expression ? RemoveUsings(exprToCode.ToCode((Expression)x)) :
|
||||||
|
x is Request ? Code(container.GetRequestExpression((Request)x).ToExpression()) :
|
||||||
|
Code(container.GetConstantExpression(x, x.GetType(), true).ToExpression());
|
||||||
|
|
||||||
|
string GetTypeNameOnly(string typeName) => typeName.Split('`').First().Split('.').Last();
|
||||||
|
|
||||||
|
string OptArg(string arg) => arg == "null" ? "" : ", " + arg;
|
||||||
|
|
||||||
|
var rootCodes = result.Roots.Select((r, i) =>
|
||||||
|
new { ServiceType = r.Key.ServiceType,
|
||||||
|
ServiceTypeCode = Code(r.Key.ServiceType),
|
||||||
|
ServiceKeyCode = Code(r.Key.ServiceKey),
|
||||||
|
RequiredServiceTypeCode = Code(r.Key.Details.RequiredServiceType),
|
||||||
|
ExpressionCode = Code(r.Value.Body),
|
||||||
|
CreateMethodName = "Get_" + i + "_" + GetTypeNameOnly(r.Key.ServiceType.Name) });
|
||||||
|
|
||||||
|
var depCodes = result.ResolveDependencies.Select((r, i) =>
|
||||||
|
new { ServiceType = Code(r.Key.ServiceType),
|
||||||
|
ServiceKey = Code(r.Key.ServiceKey), ServiceKeyObject = r.Key.ServiceKey,
|
||||||
|
Expression = Code(r.Value),
|
||||||
|
RequiredServiceType = Code(r.Key.RequiredServiceType),
|
||||||
|
PreResolveParent = Code(r.Key.Parent),
|
||||||
|
CreateMethodName = "GetDep_" + i + "_" + GetTypeNameOnly(r.Key.ServiceType.Name) });
|
||||||
|
#>
|
||||||
|
/*
|
||||||
|
========================================================================================================
|
||||||
|
NOTE: The code below is generated automatically at compile-time and not supposed to be changed by hand.
|
||||||
|
========================================================================================================
|
||||||
|
<# var errCount = result.Errors.Count;
|
||||||
|
if (errCount == 0) { #>
|
||||||
|
Generation is completed successfully.
|
||||||
|
<# } else { #>
|
||||||
|
There are <#=errCount#> generation issues (may be not an error dependent on context):
|
||||||
|
|
||||||
|
The issues with run-time registrations may be solved by `container.RegisterPlaceholder<T>()`
|
||||||
|
in Registrations.ttinclude. Then you can replace placeholders using `DryIocZero.Container.Register`
|
||||||
|
at runtime.
|
||||||
|
|
||||||
|
<# } #>
|
||||||
|
--------------------------------------------------------------------------------------------------------
|
||||||
|
<# var eNum = 0;
|
||||||
|
foreach(var e in result.Errors) { #>
|
||||||
|
<#=++eNum#>. <#=e.Key#>
|
||||||
|
Error: <#=e.Value.Message#>
|
||||||
|
<# } #>
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq; // for Enumerable.Cast method required by LazyEnumerable<T>
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using ImTools;
|
||||||
|
|
||||||
|
// Specified `NamespaceUsings` if any:
|
||||||
|
<# foreach (var ns in NamespaceUsings) {#>
|
||||||
|
using <#=ns#>;
|
||||||
|
<#}#>
|
||||||
|
|
||||||
|
namespace DryIoc
|
||||||
|
{
|
||||||
|
partial class Container
|
||||||
|
{
|
||||||
|
partial void GetLastGeneratedFactoryID(ref int lastFactoryID)
|
||||||
|
{
|
||||||
|
lastFactoryID = <#=Factory.GetNextID()#>; // generated: equals to the last used Factory.FactoryID
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ResolveGenerated(ref object service, Type serviceType)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var index = 0;
|
||||||
|
foreach (var root in rootCodes.Where(f => f.ServiceKeyCode == "null"))
|
||||||
|
{
|
||||||
|
if (index++ > 0) WriteLine(@"
|
||||||
|
else");
|
||||||
|
#>
|
||||||
|
if (serviceType == <#=root.ServiceTypeCode#>)
|
||||||
|
service = <#=root.CreateMethodName#>(this);
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ResolveGenerated(ref object service,
|
||||||
|
Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
index = 0;
|
||||||
|
foreach (var rootGroup in rootCodes.Where(x => x.ServiceKeyCode != "null").GroupBy(x => x.ServiceTypeCode))
|
||||||
|
{
|
||||||
|
if (index++ > 0) WriteLine(@"
|
||||||
|
else");
|
||||||
|
#>
|
||||||
|
if (serviceType == <#=rootGroup.Key#>)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var innerIndex = 0;
|
||||||
|
foreach (var root in rootGroup)
|
||||||
|
{
|
||||||
|
if (innerIndex++ > 0) WriteLine(@"
|
||||||
|
else");
|
||||||
|
#>
|
||||||
|
if (<#=root.ServiceKeyCode#>.Equals(serviceKey))
|
||||||
|
service = <#=root.CreateMethodName#>(this);
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#
|
||||||
|
foreach (var depGroup in depCodes.GroupBy(x => x.ServiceType))
|
||||||
|
{
|
||||||
|
if (index++ > 0) WriteLine(@"
|
||||||
|
else");
|
||||||
|
#>
|
||||||
|
if (serviceType == <#=depGroup.Key#>)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
var innerIndex = 0;
|
||||||
|
foreach (var dep in depGroup)
|
||||||
|
{
|
||||||
|
if (innerIndex++ > 0) WriteLine(@"
|
||||||
|
else");
|
||||||
|
#>
|
||||||
|
if (<#=dep.ServiceKeyObject == null ? "serviceKey == null"
|
||||||
|
: dep.ServiceKeyObject is DefaultKey ? "(serviceKey == null || " + dep.ServiceKey + ".Equals(serviceKey))"
|
||||||
|
: dep.ServiceKey + ".Equals(serviceKey)"#> &&
|
||||||
|
requiredServiceType == <#= dep.RequiredServiceType #> &&
|
||||||
|
Equals(preRequestParent, <#= dep.PreResolveParent #>))
|
||||||
|
service = <#=dep.CreateMethodName#>(this);
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ResolveManyGenerated(ref IEnumerable<ResolveManyResult> services, Type serviceType)
|
||||||
|
{
|
||||||
|
services = ResolveManyGenerated(serviceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<ResolveManyResult> ResolveManyGenerated(Type serviceType)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
if (!rootCodes.Any())
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
yield break;
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var rootGroup in rootCodes.GroupBy(x => x.ServiceType))
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
if (serviceType == <#=rootGroup.First().ServiceTypeCode#>)
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
foreach (var root in rootGroup)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
yield return ResolveManyResult.Of(<#=root.CreateMethodName#><#=OptArg(root.ServiceKeyCode)#><#=OptArg(root.RequiredServiceTypeCode)#>);
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeVariants && rootGroup.Key.IsGeneric())
|
||||||
|
{
|
||||||
|
var sourceType = rootGroup.Key;
|
||||||
|
var variants = rootCodes
|
||||||
|
.Where(x => x.ServiceType.IsGeneric() &&
|
||||||
|
x.ServiceType.GetGenericTypeDefinition() == sourceType.GetGenericTypeDefinition() &&
|
||||||
|
x.ServiceType != sourceType && x.ServiceType.IsAssignableTo(sourceType));
|
||||||
|
foreach (var variant in variants)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
yield return ResolveManyResult.Of(<#=variant.CreateMethodName#><#=OptArg(variant.ServiceKeyCode)#><#=OptArg(variant.RequiredServiceTypeCode)#>); // co-variant
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
foreach (var root in rootCodes)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
// <#=root.ServiceTypeCode#>
|
||||||
|
internal static object <#=root.CreateMethodName#>(IResolverContext r)
|
||||||
|
{
|
||||||
|
return <#=root.ExpressionCode#>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
<#
|
||||||
|
foreach (var dep in depCodes)
|
||||||
|
{
|
||||||
|
#>
|
||||||
|
// <#=dep.ServiceType#>
|
||||||
|
internal static object <#=dep.CreateMethodName#>(IResolverContext r)
|
||||||
|
{
|
||||||
|
return <#=dep.Expression#>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
}
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013-2020 Maksim Volkau
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
+6198
File diff suppressed because it is too large
Load Diff
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
+6198
File diff suppressed because it is too large
Load Diff
+14042
File diff suppressed because it is too large
Load Diff
+2789
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+2789
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+2789
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+14042
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+2789
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+4739
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+6198
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
+37
@@ -0,0 +1,37 @@
|
|||||||
|
Hello Sailor,
|
||||||
|
|
||||||
|
DryIoc now has an *optional* COMPILE-TIME dependency injection with the source package.
|
||||||
|
(previously it was available as a separate DryIocZero package)
|
||||||
|
|
||||||
|
You may ignore this information if you don't want to use the compile-time DI.
|
||||||
|
Everything will work without it!
|
||||||
|
|
||||||
|
How to use:
|
||||||
|
|
||||||
|
1. Copy contents of "%USERPROFILE%\.nuget\packages\DryIoc\<version>\CompileTimeDI\" folder
|
||||||
|
to your project - e.g. "Container.Generated.tt", "CompileTimeRegistrations.ttinclude", and "CompileTimeRegistrations.Example.cs".
|
||||||
|
2. Add your registrations into the "CompileTimeRegistrations.ttinclude" file - the file already contains
|
||||||
|
the registrations from the "CompileTimeGenerate.Example.cs", you may remove them later.
|
||||||
|
3. Save (or re-save) the "Container.Generated.tt" file in the Visual Studio or JetBrains Rider
|
||||||
|
(you may get a prompt - accept it). If everything is fine you will see the generated "Container.Generated.cs"
|
||||||
|
file under the "Container.Generated.tt" in Solution Explorer. The "Container.Generated.cs" will contain
|
||||||
|
the generated methods to create the services registered in "CompileTimeRegistrations.ttinclude"
|
||||||
|
|
||||||
|
|
||||||
|
Troubleshooting:
|
||||||
|
|
||||||
|
1. If you see the errors in "Container.Generated.tt" file with the namespaces not being resolved,
|
||||||
|
please ensure that "DryIoc.props" is copied to your project from the DryIoc package installation,
|
||||||
|
e.g. from the "%USERPROFILE%\.nuget\packages\DryIoc\<version>\build\DryIoc.props"
|
||||||
|
2. Edit the target ".csproj" file and add closer to the top the following Import:
|
||||||
|
|
||||||
|
<Import Project="DryIoc.props" />
|
||||||
|
|
||||||
|
3. Edit the "DryIoc.props" to ensure the path to "ExpressionToCodeLib.dll" points to the correct location in
|
||||||
|
the DryIoc package installation.
|
||||||
|
4. If some of System assemblies are not loading try the accepted answer from the
|
||||||
|
https://stackoverflow.com/questions/51550265/t4-template-could-not-load-file-or-assembly-system-runtime-version-4-2-0-0
|
||||||
|
|
||||||
|
|
||||||
|
For editing and viewing the T4 text template files you may use ForTea plugin for JetBrains ReSharper
|
||||||
|
https://plugins.jetbrains.com/plugin/11634-fortea (or JetBrains Rider with the native T4 support)
|
||||||
Vendored
Executable
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user