mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-11-23 03:33:44 +00:00
Added DisposableBase to library.
Replaced Machine.GetCards<T> with Machine.Slots.OfType<T>.
This commit is contained in:
parent
06b887699a
commit
b24bcd767e
26
Library/DisposableBase.cs
Normal file
26
Library/DisposableBase.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Jellyfish.Library
|
||||
{
|
||||
public abstract class DisposableBase : IDisposable
|
||||
{
|
||||
protected DisposableBase()
|
||||
{
|
||||
}
|
||||
|
||||
~DisposableBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -10,14 +10,14 @@
|
||||
|
||||
namespace Jellyfish.Library
|
||||
{
|
||||
public class ApplicationBase : Application
|
||||
public abstract class ApplicationBase : Application
|
||||
{
|
||||
public ApplicationBase() :
|
||||
protected ApplicationBase() :
|
||||
this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ApplicationBase(string name)
|
||||
protected ApplicationBase(string name)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
|
@ -74,6 +74,9 @@
|
||||
<Compile Include="..\DispatcherExtensions.cs">
|
||||
<Link>DispatcherExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\FrameRateCounter.xaml.cs">
|
||||
<Link>FrameRateCounter.xaml.cs</Link>
|
||||
<DependentUpon>FrameRateCounter.xaml</DependentUpon>
|
||||
|
@ -68,6 +68,9 @@
|
||||
<Compile Include="..\..\DispatcherExtensions.cs">
|
||||
<Link>DispatcherExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
|
@ -7,16 +7,16 @@
|
||||
|
||||
namespace Jellyfish.Library
|
||||
{
|
||||
public class ApplicationBase : Application
|
||||
public abstract class ApplicationBase : Application
|
||||
{
|
||||
[SecurityCritical]
|
||||
public ApplicationBase() :
|
||||
protected ApplicationBase() :
|
||||
this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
public ApplicationBase(string name)
|
||||
protected ApplicationBase(string name)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
|
@ -66,6 +66,9 @@
|
||||
<Compile Include="..\DispatcherExtensions.cs">
|
||||
<Link>DispatcherExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\FrameRateCounter.xaml.cs">
|
||||
<Link>FrameRateCounter.xaml.cs</Link>
|
||||
<DependentUpon>FrameRateCounter.xaml</DependentUpon>
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
namespace Jellyfish.Library
|
||||
{
|
||||
public class GameBase : Game
|
||||
public abstract class GameBase : Game
|
||||
{
|
||||
public GameBase(string name)
|
||||
protected GameBase(string name)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
|
@ -88,6 +88,9 @@
|
||||
<Compile Include="..\AssemblyCommentAttribute.cs">
|
||||
<Link>AssemblyCommentAttribute.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
|
@ -103,6 +103,9 @@
|
||||
<Compile Include="..\AssemblyCommentAttribute.cs">
|
||||
<Link>AssemblyCommentAttribute.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
|
@ -106,6 +106,9 @@
|
||||
<Compile Include="..\AssemblyCommentAttribute.cs">
|
||||
<Link>AssemblyCommentAttribute.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\DisposableBase.cs">
|
||||
<Link>DisposableBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\GCHandleHelpers.cs">
|
||||
<Link>GCHandleHelpers.cs</Link>
|
||||
</Compile>
|
||||
|
@ -48,11 +48,6 @@ public void Dispose()
|
||||
_unpauseEvent.Close();
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetCards<T>() where T : PeripheralCard
|
||||
{
|
||||
return Slots.Where(card => card is T).Cast<T>();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
foreach (var component in Components)
|
||||
@ -192,7 +187,7 @@ private void Run() // machine thread
|
||||
{
|
||||
//_debugService = Services.GetService<DebugService>();
|
||||
_storageService = Services.GetService<StorageService>();
|
||||
_bootDiskII = GetCards<DiskIIController>().Last();
|
||||
_bootDiskII = Slots.OfType<DiskIIController>().Last();
|
||||
|
||||
Initialize();
|
||||
Reset();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Jellyfish.Virtu.Services
|
||||
{
|
||||
public abstract class MachineService : IDisposable
|
||||
public abstract class MachineService : DisposableBase
|
||||
{
|
||||
protected MachineService(Machine machine)
|
||||
{
|
||||
@ -12,21 +12,6 @@ protected MachineService(Machine machine)
|
||||
_debugService = new Lazy<DebugService>(() => Machine.Services.GetService<DebugService>());
|
||||
}
|
||||
|
||||
~MachineService()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
protected Machine Machine { get; private set; }
|
||||
protected DebugService DebugService { get { return _debugService.Value; } }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user