Cosmetic changes.

Fixed some code analysis warnings.
Dropped Extended Strongly Typed Resource Generator dependency.

--HG--
extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4035615
This commit is contained in:
Sean Fausett 2009-12-11 09:12:31 +00:00
parent 8cb42c970d
commit acd7892436
31 changed files with 683 additions and 577 deletions

View File

@ -9,6 +9,11 @@ namespace Jellyfish.Library
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
public static void Pin(object value, Action<IntPtr> action)
{
if (action == null)
{
throw new ArgumentNullException("action");
}
GCHandle gcHandle = new GCHandle();
try
{

View File

@ -127,6 +127,11 @@ namespace Jellyfish.Library
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
public static void GetSecurityAttributes(ObjectSecurity security, bool inheritable, Action<SecurityAttributes> action)
{
if (action == null)
{
throw new ArgumentNullException("action");
}
if (security != null)
{
GCHandleHelpers.Pin(security.GetSecurityDescriptorBinaryForm(), securityDescriptor =>

View File

@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Jellyfish.Library.FrameRateCounter.#frameRateControl")]

View File

@ -7,6 +7,15 @@ namespace Jellyfish.Library
{
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (action == null)
{
throw new ArgumentNullException("action");
}
foreach (T item in source)
{
action(item);

View File

@ -42,6 +42,11 @@ namespace Jellyfish.Library
public static SafeGlobalAllocHandle Allocate(byte[] value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
SafeGlobalAllocHandle alloc = Allocate(value.Length);
Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length);
@ -100,6 +105,11 @@ namespace Jellyfish.Library
public static SafeLocalAllocHandle Allocate(byte[] value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
SafeLocalAllocHandle alloc = Allocate(value.Length);
Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length);

View File

@ -54,6 +54,11 @@ namespace Jellyfish.Library
public void SetAccessControl(GeneralSecurity fileSecurity)
{
if (fileSecurity == null)
{
throw new ArgumentNullException("fileSecurity");
}
fileSecurity.Persist(this);
}

View File

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
namespace Jellyfish.Library
{
@ -6,6 +7,11 @@ namespace Jellyfish.Library
{
public static byte[] ReadAllBytes(this Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
int count = (int)stream.Length;
byte[] buffer = new byte[count];
ReadBlock(stream, buffer, 0, count);
@ -15,6 +21,11 @@ namespace Jellyfish.Library
public static int ReadBlock(this Stream stream, byte[] buffer, int offset, int count)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
int total = 0;
int read;
do

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]

View File

@ -42,102 +42,111 @@
</Rules>
<FxCopReport Version="1.36">
<Targets>
<Target Name="$(ProjectDir)/Wpf/bin/Jellyfish.Virtu.exe">
<Modules>
<Module Name="jellyfish.virtu.exe">
<Namespaces>
<Namespace Name="Jellyfish.Virtu">
<Types>
<Type Name="DiskDsk">
<Members>
<Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages>
<Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'nibble'</Item>
<Item>'byte'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
<Messages>
<Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue Name="TooGeneric">
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue>
</Message>
<Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'readVolume'</Item>
<Item>'int'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="MainWindow">
<Members>
<Member Name="#System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object)">
<Messages>
<Message TypeName="DoNotCastUnnecessarily" Category="Microsoft.Performance" CheckId="CA1800" Created="2009-12-11 09:07:49Z">
<Issue Name="Parameter">
<Item>'target'</Item>
<Item>'Button'</Item>
<Item>'MainWindow.IComponentConnector.Connect(int, object)'</Item>
<Item>castclass</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Video">
<Members>
<Member Name="#ReadFloatingBus()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-12-11 09:07:49Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Video.ReadFloatingBus()'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
</Types>
</Namespace>
</Namespaces>
</Module>
</Modules>
</Target>
<Target Name="$(ProjectDir)/Xna/bin/Jellyfish.Virtu.exe">
<Modules>
<Module Name="jellyfish.virtu.exe">
<Namespaces>
<Namespace Name="Jellyfish.Virtu">
<Types>
<Type Name="Disk525">
<Messages>
<Message TypeName="AbstractTypesShouldNotHaveConstructors" Category="Microsoft.Design" CheckId="CA1012" Created="2009-04-13 00:02:55Z">
<Issue>
<Item>'Disk525'</Item>
</Issue>
</Message>
</Messages>
<Type Name="DiskDsk">
<Members>
<Member Name="#.ctor(System.String,System.Byte[])">
<Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages>
<Message Id="fileData" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'fileData'</Item>
<Item>'Disk525.Disk525(string, byte[])'</Item>
</Issue>
</Message>
<Message Id="fileName" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'fileName'</Item>
<Item>'Disk525.Disk525(string, byte[])'</Item>
<Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'nibble'</Item>
<Item>'byte'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="DiskII">
<Members>
<Member Name="#_writeModeOn">
<Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
<Messages>
<Message TypeName="AvoidUnusedPrivateFields" Category="Microsoft.Performance" CheckId="CA1823" Created="2009-04-13 00:02:55Z">
<Issue>
<Item>'DiskII._writeModeOn'</Item>
<Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue Name="TooGeneric">
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#Write(System.Int32,System.Int32)">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskII.Write(int, int)'</Item>
</Issue>
</Message>
<Message Id="address" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'address'</Item>
<Item>'DiskII.Write(int, int)'</Item>
</Issue>
</Message>
<Message Id="data" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'data'</Item>
<Item>'DiskII.Write(int, int)'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Drive525">
<Members>
<Member Name="#driveArmStepDelta">
<Messages>
<Message Id="Member" TypeName="PreferJaggedArraysOverMultidimensional" Category="Microsoft.Performance" CheckId="CA1814" Created="2009-04-13 00:02:55Z">
<Issue>
<Item>'Drive525.driveArmStepDelta'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#Reset()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Drive525.Reset()'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Speaker">
<Members>
<Member Name="#ToggleOutput()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Speaker.ToggleOutput()'</Item>
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'readVolume'</Item>
<Item>'int'</Item>
</Issue>
</Message>
</Messages>
@ -165,20 +174,17 @@
</Target>
</Targets>
<Rules>
<Rule TypeName="AbstractTypesShouldNotHaveConstructors" Category="Microsoft.Design" CheckId="CA1012">
<Resolution Name="Default">Change the accessibility of all public constructors in {0} to protected.</Resolution>
<Rule TypeName="DoNotCastUnnecessarily" Category="Microsoft.Performance" CheckId="CA1800">
<Resolution Name="Parameter">{0}, a parameter, is cast to type {1} multiple times in method {2}. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant {3} instruction.</Resolution>
</Rule>
<Rule TypeName="AvoidUnusedPrivateFields" Category="Microsoft.Performance" CheckId="CA1823">
<Resolution Name="Default">It appears that field {0} is never used or is only ever assigned to. Use this field or remove it.</Resolution>
<Rule TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201">
<Resolution Name="TooGeneric">{0} creates an exception of type {1}, an exception type that is not sufficiently specific and should never be raised by user code. If this exception instance might be thrown, use a different exception type.</Resolution>
</Rule>
<Rule TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822">
<Resolution Name="Default">The 'this' parameter (or 'Me' in Visual Basic) of {0} is never used. Mark the member as static (or Shared in Visual Basic) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate.</Resolution>
</Rule>
<Rule TypeName="PreferJaggedArraysOverMultidimensional" Category="Microsoft.Performance" CheckId="CA1814">
<Resolution Name="Default">{0} is a multidimensional array. Replace it with a jagged array if possible.</Resolution>
</Rule>
<Rule TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801">
<Resolution Name="Default">Parameter {0} of {1} is never used. Remove the parameter or use it in the method body.</Resolution>
<Rule TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804">
<Resolution Name="Default">{0} declares a variable, {1}, of type {2}, which is never used or is only assigned to. Use this variable or remove it.</Resolution>
</Rule>
</Rules>
</FxCopReport>

View File

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Resources;
using Jellyfish.Library;
@ -1376,7 +1377,7 @@ namespace Jellyfish.Virtu
Stream romStream = (Stream)resourceManager.GetObject(romName);
if (romStream.Length != romSize)
{
throw new InvalidOperationException(SR.RomInvalidFormat(romName));
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.RomInvalid, romName));
}
return romStream;

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4016
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -13,147 +13,78 @@ namespace Jellyfish.Virtu.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, formatting them, etc.
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilderEx class via the ResXFileCodeGeneratorEx custom tool.
// To add or remove a member, edit your .ResX file then rerun the ResXFileCodeGeneratorEx custom tool or rebuild your VS.NET project.
// Copyright (c) Dmytro Kryvko 2006-2009 (http://dmytro.kryvko.googlepages.com/)
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderEx", "2.4.0.0")]
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces")]
public partial class SR {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class SR {
private static global::System.Resources.ResourceManager _resourceManager;
private static global::System.Resources.ResourceManager resourceMan;
private static object _internalSyncObject;
private static global::System.Globalization.CultureInfo _resourceCulture;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public SR() {
internal SR() {
}
/// <summary>
/// Thread safe lock object used by this class.
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
public static object InternalSyncObject {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(_internalSyncObject, null)) {
global::System.Threading.Interlocked.CompareExchange(ref _internalSyncObject, new object(), null);
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Jellyfish.Virtu.Properties.SR", typeof(SR).Assembly);
resourceMan = temp;
}
return _internalSyncObject;
return resourceMan;
}
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
internal static global::System.Globalization.CultureInfo Culture {
get {
if (object.ReferenceEquals(_resourceManager, null)) {
global::System.Threading.Monitor.Enter(InternalSyncObject);
try {
if (object.ReferenceEquals(_resourceManager, null)) {
global::System.Threading.Interlocked.Exchange(ref _resourceManager, new global::System.Resources.ResourceManager("Jellyfish.Virtu.Properties.SR", typeof(SR).Assembly));
}
}
finally {
global::System.Threading.Monitor.Exit(InternalSyncObject);
}
}
return _resourceManager;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return _resourceCulture;
return resourceCulture;
}
set {
_resourceCulture = value;
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 'Rom &apos;{0}&apos; invalid.'.
/// Looks up a localized string similar to Rom &apos;{0}&apos; invalid..
/// </summary>
public static string RomInvalid {
internal static string RomInvalid {
get {
return ResourceManager.GetString(ResourceNames.RomInvalid, _resourceCulture);
return ResourceManager.GetString("RomInvalid", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 'Service type &apos;{0}&apos; already present.'.
/// Looks up a localized string similar to Service type &apos;{0}&apos; already present..
/// </summary>
public static string ServiceAlreadyPresent {
internal static string ServiceAlreadyPresent {
get {
return ResourceManager.GetString(ResourceNames.ServiceAlreadyPresent, _resourceCulture);
return ResourceManager.GetString("ServiceAlreadyPresent", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 'Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;.'.
/// Looks up a localized string similar to Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;..
/// </summary>
public static string ServiceMustBeAssignable {
internal static string ServiceMustBeAssignable {
get {
return ResourceManager.GetString(ResourceNames.ServiceMustBeAssignable, _resourceCulture);
return ResourceManager.GetString("ServiceMustBeAssignable", resourceCulture);
}
}
/// <summary>
/// Formats a localized string similar to 'Rom &apos;{0}&apos; invalid.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string RomInvalidFormat(object arg0) {
return string.Format(_resourceCulture, RomInvalid, arg0);
}
/// <summary>
/// Formats a localized string similar to 'Service type &apos;{0}&apos; already present.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string ServiceAlreadyPresentFormat(object arg0) {
return string.Format(_resourceCulture, ServiceAlreadyPresent, arg0);
}
/// <summary>
/// Formats a localized string similar to 'Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <param name="arg1">An object (1) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string ServiceMustBeAssignableFormat(object arg0, object arg1) {
return string.Format(_resourceCulture, ServiceMustBeAssignable, arg0, arg1);
}
/// <summary>
/// Lists all the resource names as constant string fields.
/// </summary>
public class ResourceNames {
/// <summary>
/// Stores the resource name 'RomInvalid'.
/// </summary>
public const string RomInvalid = "RomInvalid";
/// <summary>
/// Stores the resource name 'ServiceAlreadyPresent'.
/// </summary>
public const string ServiceAlreadyPresent = "ServiceAlreadyPresent";
/// <summary>
/// Stores the resource name 'ServiceMustBeAssignable'.
/// </summary>
public const string ServiceMustBeAssignable = "ServiceMustBeAssignable";
}
}
}

View File

@ -25,6 +25,11 @@ namespace Jellyfish.Virtu.Services
protected void Update(int bufferSize, Action<byte[], int> updateBuffer) // audio thread
{
if (updateBuffer == null)
{
throw new ArgumentNullException("updateBuffer");
}
lock (_lock)
{
long cycles = Machine.Cpu.Cycles;

View File

@ -6,6 +6,11 @@ namespace Jellyfish.Virtu.Services
{
protected MachineService(Machine machine)
{
if (machine == null)
{
throw new ArgumentNullException("machine");
}
Machine = machine;
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Jellyfish.Virtu.Properties;
namespace Jellyfish.Virtu.Services
@ -9,13 +10,21 @@ namespace Jellyfish.Virtu.Services
{
public void AddService(Type serviceType, MachineService serviceProvider)
{
if (serviceType == null)
{
throw new ArgumentNullException("serviceType");
}
if (_serviceProviders.ContainsKey(serviceType))
{
throw new ArgumentException(SR.ServiceAlreadyPresentFormat(serviceType.FullName), "serviceType");
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ServiceAlreadyPresent, serviceType.FullName), "serviceType");
}
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
if (!serviceType.IsAssignableFrom(serviceProvider.GetType()))
{
throw new ArgumentException(SR.ServiceMustBeAssignableFormat(serviceType.FullName, serviceProvider.GetType().FullName));
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ServiceMustBeAssignable, serviceType.FullName, serviceProvider.GetType().FullName));
}
_serviceProviders.Add(serviceType, serviceProvider);

View File

@ -95,6 +95,9 @@
<Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link>
</Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link>
</Compile>
@ -186,7 +189,7 @@
<ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

View File

@ -1,4 +1,5 @@
using System.Windows.Controls;
using System;
using System.Windows.Controls;
namespace Jellyfish.Virtu.Services
{
@ -7,6 +8,15 @@ namespace Jellyfish.Virtu.Services
public SilverlightAudioService(Machine machine, UserControl page, MediaElement media) :
base(machine)
{
if (page == null)
{
throw new ArgumentNullException("page");
}
if (media == null)
{
throw new ArgumentNullException("media");
}
_page = page;
_media = media;

View File

@ -12,6 +12,11 @@ namespace Jellyfish.Virtu.Services
public SilverlightKeyboardService(Machine machine, UserControl page) :
base(machine)
{
if (page == null)
{
throw new ArgumentNullException("page");
}
_page = page;
_page.KeyDown += Page_KeyDown;

View File

@ -13,6 +13,11 @@ namespace Jellyfish.Virtu.Services
public override void Load(string path, Action<Stream> reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
@ -33,6 +38,11 @@ namespace Jellyfish.Virtu.Services
public override void Save(string path, Action<Stream> writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
try
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())

View File

@ -12,7 +12,13 @@ namespace Jellyfish.Virtu.Services
public SilverlightVideoService(Machine machine, Image image) :
base(machine)
{
if (image == null)
{
throw new ArgumentNullException("image");
}
_image = image;
_image.Source = _bitmap;
SetImageSize();

View File

@ -111,6 +111,9 @@
<Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link>
</Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Services\AudioService.cs">
<Link>Services\AudioService.cs</Link>
</Compile>
@ -189,7 +192,7 @@
<ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

View File

@ -15,7 +15,7 @@ namespace Jellyfish.Virtu
_storageService = new WpfStorageService(_machine);
_keyboardService = new WpfKeyboardService(_machine, this);
_gamePortService = new XnaGamePortService(_machine);
_gamePortService = new GamePortService(_machine); // not connected
_audioService = new WpfAudioService(_machine, this);
_videoService = new WpfVideoService(_machine, this, _image);

View File

@ -10,6 +10,11 @@ namespace Jellyfish.Virtu.Services
public WpfAudioService(Machine machine, Window window) :
base(machine)
{
if (window == null)
{
throw new ArgumentNullException("window");
}
_window = window;
_window.SourceInitialized += (sender, e) => _directSound.Start(_window.GetHandle());
@ -23,6 +28,8 @@ namespace Jellyfish.Virtu.Services
{
_directSound.Dispose();
}
base.Dispose(disposing);
}
private void DirectSound_Update(object sender, DirectSoundUpdateEventArgs e)

View File

@ -11,6 +11,11 @@ namespace Jellyfish.Virtu.Services
public WpfKeyboardService(Machine machine, Window window) :
base(machine)
{
if (window == null)
{
throw new ArgumentNullException("window");
}
_window = window;
_window.KeyDown += Window_KeyDown;

View File

@ -14,6 +14,11 @@ namespace Jellyfish.Virtu.Services
public override void Load(string path, Action<Stream> reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try
{
using (IsolatedStorageFile store = GetStore())
@ -34,6 +39,11 @@ namespace Jellyfish.Virtu.Services
public override void Save(string path, Action<Stream> writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
try
{
using (IsolatedStorageFile store = GetStore())

View File

@ -15,8 +15,18 @@ namespace Jellyfish.Virtu.Services
public WpfVideoService(Machine machine, Window window, Image image) :
base(machine)
{
if (window == null)
{
throw new ArgumentNullException("window");
}
if (image == null)
{
throw new ArgumentNullException("image");
}
_window = window;
_image = image;
_image.Source = _bitmap;
SetImageSize();

View File

@ -92,6 +92,9 @@
<Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link>
</Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link>
</Compile>
@ -211,7 +214,7 @@
<ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

View File

@ -113,6 +113,9 @@
<Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link>
</Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link>
</Compile>
@ -225,7 +228,7 @@
<ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

View File

@ -10,6 +10,11 @@ namespace Jellyfish.Virtu.Services
public XnaAudioService(Machine machine, GameBase game) :
base(machine)
{
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game;
_directSound.Start(_game.Window.Handle);

View File

@ -11,11 +11,21 @@ namespace Jellyfish.Virtu.Services
public XnaStorageService(Machine machine, GameBase game) :
base(machine)
{
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game;
}
public override void Load(string path, Action<Stream> reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try
{
using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name))
@ -33,6 +43,11 @@ namespace Jellyfish.Virtu.Services
public override void Save(string path, Action<Stream> writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name))
{
using (FileStream stream = new FileStream(Path.Combine(storageContainer.Path, path), FileMode.Create, FileAccess.Write, FileShare.None))

View File

@ -11,6 +11,11 @@ namespace Jellyfish.Virtu.Services
public XnaVideoService(Machine machine, GameBase game) :
base(machine)
{
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game;
_game.GraphicsDeviceManager.PreparingDeviceSettings += GraphicsDeviceManager_PreparingDeviceSettings;