Revert "Replace dynamic type w/ casts in CoreInventory/CLP"

This reverts commit 9ee4821148.

# Conflicts:
#	src/BizHawk.Emulation.Cores/CoreLoadParameters.cs

This didn't actually work, so revisit later
This commit is contained in:
nattthebear 2020-07-12 10:18:08 -04:00
parent f41a70ef32
commit 81d0b4ec9e
3 changed files with 6 additions and 19 deletions

View File

@ -5,6 +5,7 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Memory" Version="4.5.4" /> <PackageReference Include="System.Memory" Version="4.5.4" />
<Reference Include="FlatBuffers.Core" HintPath="$(ProjectDir)../../References/FlatBuffers.Core.dll" Private="true" /> <Reference Include="FlatBuffers.Core" HintPath="$(ProjectDir)../../References/FlatBuffers.Core.dll" Private="true" />
<Reference Include="Virtu" HintPath="$(ProjectDir)../../References/Virtu.dll" Private="true" /> <Reference Include="Virtu" HintPath="$(ProjectDir)../../References/Virtu.dll" Private="true" />

View File

@ -114,11 +114,13 @@ namespace BizHawk.Emulation.Cores
{ {
if (_useCoreLoadParameters) if (_useCoreLoadParameters)
{ {
var paramType = typeof(CoreLoadParameters<,>).MakeGenericType(new[] { SettingsType, SyncSettingsType });
// TODO: clean this up // TODO: clean this up
var param = (ICoreLoadParameters<object, object>) Activator.CreateInstance(typeof(CoreLoadParameters<,>).MakeGenericType(SettingsType, SyncSettingsType)); dynamic param = Activator.CreateInstance(paramType);
param.Comm = comm; param.Comm = comm;
param.Game = game; param.Game = game;
param.PutSettings(settings, syncSettings); param.Settings = (dynamic)settings;
param.SyncSettings = (dynamic)syncSettings;
param.Roms.Add(new RomGameFake param.Roms.Add(new RomGameFake
{ {
RomData = rom, RomData = rom,

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -24,15 +23,7 @@ namespace BizHawk.Emulation.Cores
DiscType DiscType { get; } DiscType DiscType { get; }
public string DiscName { get; set; } public string DiscName { get; set; }
} }
internal interface ICoreLoadParameters<in TSettiing, in TSync> public class CoreLoadParameters<TSettiing, TSync>
{
CoreComm Comm { set; }
GameInfo Game { set; }
List<IRomAsset> Roms { get; }
bool DeterministicEmulationRequested { set; }
void PutSettings(object settings, object syncSettings);
}
public class CoreLoadParameters<TSettiing, TSync> : ICoreLoadParameters<TSettiing, TSync>
{ {
public CoreComm Comm { get; set; } public CoreComm Comm { get; set; }
public GameInfo Game { get; set; } public GameInfo Game { get; set; }
@ -56,12 +47,5 @@ namespace BizHawk.Emulation.Cores
/// <value></value> /// <value></value>
public List<IDiscAsset> Discs { get; set; } = new List<IDiscAsset>(); public List<IDiscAsset> Discs { get; set; } = new List<IDiscAsset>();
public bool DeterministicEmulationRequested { get; set; } public bool DeterministicEmulationRequested { get; set; }
void ICoreLoadParameters<TSettiing, TSync>.PutSettings(object settings, object syncSettings)
{
if (!(settings is TSettiing typedSettings)) throw new ArgumentException("type does not match type param", nameof(settings));
if (!(syncSettings is TSync typedSyncSettings)) throw new ArgumentException("type does not match type param", nameof(syncSettings));
Settings = typedSettings;
SyncSettings = typedSyncSettings;
}
} }
} }