Replace dynamic type w/ casts in CoreInventory/CLP
dynamic introduced in cc9d7df9f
This commit is contained in:
parent
c712bde84e
commit
9ee4821148
|
@ -5,7 +5,6 @@
|
|||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
<Reference Include="FlatBuffers.Core" HintPath="$(ProjectDir)../../References/FlatBuffers.Core.dll" Private="true" />
|
||||
<Reference Include="Virtu" HintPath="$(ProjectDir)../../References/Virtu.dll" Private="true" />
|
||||
|
|
|
@ -113,13 +113,11 @@ namespace BizHawk.Emulation.Cores
|
|||
{
|
||||
if (_useCoreLoadParameters)
|
||||
{
|
||||
var paramType = typeof(CoreLoadParameters<,>).MakeGenericType(new[] { SettingsType, SyncSettingsType });
|
||||
// TODO: clean this up
|
||||
dynamic param = Activator.CreateInstance(paramType);
|
||||
var param = (ICoreLoadParameters<object, object>) Activator.CreateInstance(typeof(CoreLoadParameters<,>).MakeGenericType(SettingsType, SyncSettingsType));
|
||||
param.Comm = comm;
|
||||
param.Game = game;
|
||||
param.Settings = (dynamic)settings;
|
||||
param.SyncSettings = (dynamic)syncSettings;
|
||||
param.PutSettings(settings, syncSettings);
|
||||
param.Roms.Add(new RomGameFake
|
||||
{
|
||||
RomData = rom,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -17,7 +18,15 @@ namespace BizHawk.Emulation.Cores
|
|||
DiscType DiscType { get; }
|
||||
public string DiscName { get; set; }
|
||||
}
|
||||
public class CoreLoadParameters<TSettiing, TSync>
|
||||
internal interface ICoreLoadParameters<in TSettiing, in TSync>
|
||||
{
|
||||
CoreComm Comm { set; }
|
||||
GameInfo Game { set; }
|
||||
List<IRomGame> 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 GameInfo Game { get; set; }
|
||||
|
@ -41,5 +50,12 @@ namespace BizHawk.Emulation.Cores
|
|||
/// <value></value>
|
||||
public List<IDiscGame> Discs { get; set; } = new List<IDiscGame>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue