Removed some XNA 3.1 code paths; cleaned up constant usage in platform-specific code sections
git-svn-id: file:///srv/devel/repo-conversion/nusu@211 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
645148a751
commit
46cbc920b1
|
@ -19,7 +19,7 @@
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\net-4.0\Debug\</OutputPath>
|
<OutputPath>bin\net-4.0\Debug\</OutputPath>
|
||||||
<DefineConstants>TRACE;DEBUG;UNITTEST</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;UNITTEST;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<DocumentationFile>bin\net-4.0\Debug\Nuclex.Support.xml</DocumentationFile>
|
<DocumentationFile>bin\net-4.0\Debug\Nuclex.Support.xml</DocumentationFile>
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\net-4.0\Release\</OutputPath>
|
<OutputPath>bin\net-4.0\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE;UNITTEST</DefineConstants>
|
<DefineConstants>TRACE;UNITTEST;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<DocumentationFile>bin\net-4.0\Release\Nuclex.Support.xml</DocumentationFile>
|
<DocumentationFile>bin\net-4.0\Release\Nuclex.Support.xml</DocumentationFile>
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace Nuclex.Support {
|
||||||
// explicitly move it to that core. MSDN states that SetProcessorAffinity() should
|
// explicitly move it to that core. MSDN states that SetProcessorAffinity() should
|
||||||
// be called from the thread whose affinity is being changed.
|
// be called from the thread whose affinity is being changed.
|
||||||
Thread.CurrentThread.SetProcessorAffinity(new int[] { hardwareThreadIndex });
|
Thread.CurrentThread.SetProcessorAffinity(new int[] { hardwareThreadIndex });
|
||||||
#elif !WINDOWS_PHONE
|
#elif WINDOWS
|
||||||
if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||||
// Prevent this managed thread from impersonating another system thread.
|
// Prevent this managed thread from impersonating another system thread.
|
||||||
// In .NET, managed threads can supposedly be moved to different system threads
|
// In .NET, managed threads can supposedly be moved to different system threads
|
||||||
|
@ -237,7 +237,7 @@ namespace Nuclex.Support {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !XBOX360 && !WINDOWS_PHONE
|
#if WINDOWS
|
||||||
/// <summary>Retrieves the ProcessThread for the calling thread</summary>
|
/// <summary>Retrieves the ProcessThread for the calling thread</summary>
|
||||||
/// <returns>The ProcessThread for the calling thread</returns>
|
/// <returns>The ProcessThread for the calling thread</returns>
|
||||||
internal static ProcessThread GetProcessThread(int threadId) {
|
internal static ProcessThread GetProcessThread(int threadId) {
|
||||||
|
@ -282,7 +282,7 @@ namespace Nuclex.Support {
|
||||||
/// <summary>Delegate used to handle assertion checks in the code</summary>
|
/// <summary>Delegate used to handle assertion checks in the code</summary>
|
||||||
public static volatile ExceptionDelegate ExceptionHandler = DefaultExceptionHandler;
|
public static volatile ExceptionDelegate ExceptionHandler = DefaultExceptionHandler;
|
||||||
|
|
||||||
#if !XBOX360 // Only called if platform is Win32NT
|
#if WINDOWS
|
||||||
/// <summary>Retrieves the calling thread's thread id</summary>
|
/// <summary>Retrieves the calling thread's thread id</summary>
|
||||||
/// <returns>The thread is of the calling thread</returns>
|
/// <returns>The thread is of the calling thread</returns>
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
|
|
|
@ -294,11 +294,11 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
index += this.firstBlockStartIndex;
|
index += this.firstBlockStartIndex;
|
||||||
#if XBOX360 || WINDOWS_PHONE
|
#if WINDOWS
|
||||||
|
blockIndex = Math.DivRem(index, this.blockSize, out subIndex);
|
||||||
|
#else
|
||||||
blockIndex = index / this.blockSize;
|
blockIndex = index / this.blockSize;
|
||||||
subIndex = index % this.blockSize;
|
subIndex = index % this.blockSize;
|
||||||
#else
|
|
||||||
blockIndex = Math.DivRem(index, this.blockSize, out subIndex);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@ using NUnit.Framework;
|
||||||
|
|
||||||
namespace Nuclex.Support.Plugins {
|
namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
#if XBOX360
|
|
||||||
|
|
||||||
/// <summary>Unit Test for the assembly load event argument container</summary>
|
/// <summary>Unit Test for the assembly load event argument container</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class AssemblyLoadEventArgsTest {
|
public class AssemblyLoadEventArgsTest {
|
||||||
|
@ -48,8 +46,6 @@ namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XBOX360
|
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Plugins
|
} // namespace Nuclex.Support.Plugins
|
||||||
|
|
||||||
#endif // UNITTEST
|
#endif // UNITTEST
|
||||||
|
|
|
@ -52,6 +52,6 @@ namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // XBOX360
|
#endif // XBOX360 || WINDOWS_PHONE
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Plugins
|
} // namespace Nuclex.Support.Plugins
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
/// <summary>Reports an error to the debugging console</summary>
|
/// <summary>Reports an error to the debugging console</summary>
|
||||||
/// <param name="error">Error message that will be reported</param>
|
/// <param name="error">Error message that will be reported</param>
|
||||||
private static void reportError(string error) {
|
private static void reportError(string error) {
|
||||||
#if !XBOX360 && !WINDOWS_PHONE
|
#if WINDOWS
|
||||||
Trace.WriteLine(error);
|
Trace.WriteLine(error);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
loadedAssembly = LoadAssemblyFromFile(path);
|
loadedAssembly = LoadAssemblyFromFile(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#if !XBOX360
|
#if WINDOWS
|
||||||
// File not found - Most likely a missing dependency of the assembly we
|
// File not found - Most likely a missing dependency of the assembly we
|
||||||
// attempted to load since the assembly itself has been found by the GetFiles() method
|
// attempted to load since the assembly itself has been found by the GetFiles() method
|
||||||
catch(DllNotFoundException) {
|
catch(DllNotFoundException) {
|
||||||
|
@ -178,7 +178,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
/// <summary>Reports an error to the debugging console</summary>
|
/// <summary>Reports an error to the debugging console</summary>
|
||||||
/// <param name="error">Error message that will be reported</param>
|
/// <param name="error">Error message that will be reported</param>
|
||||||
private static void reportError(string error) {
|
private static void reportError(string error) {
|
||||||
#if !XBOX360 && !WINDOWS_PHONE
|
#if WINDOWS
|
||||||
Trace.WriteLine(error);
|
Trace.WriteLine(error);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,13 +92,8 @@ namespace Nuclex.Support.Scheduling {
|
||||||
// Force a timeout at least each second so the caller can check the system time
|
// Force a timeout at least each second so the caller can check the system time
|
||||||
// since we're not able to provide the DateTimeAdjusted notification
|
// since we're not able to provide the DateTimeAdjusted notification
|
||||||
int milliseconds = (int)(ticks / TicksPerMillisecond);
|
int milliseconds = (int)(ticks / TicksPerMillisecond);
|
||||||
#if XNA_3
|
|
||||||
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
|
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
|
||||||
#elif XBOX360 || WINDOWS_PHONE
|
|
||||||
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds));
|
|
||||||
#else
|
|
||||||
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
|
|
||||||
#endif
|
|
||||||
// See whether the system date/time have been adjusted while we were asleep.
|
// See whether the system date/time have been adjusted while we were asleep.
|
||||||
checkForTimeAdjustment();
|
checkForTimeAdjustment();
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
|
|
||||||
this.timerThread = new Thread(new ThreadStart(runTimerThread));
|
this.timerThread = new Thread(new ThreadStart(runTimerThread));
|
||||||
this.timerThread.Name = "Nuclex.Support.Scheduling.Scheduler";
|
this.timerThread.Name = "Nuclex.Support.Scheduling.Scheduler";
|
||||||
#if XNA_3
|
#if WINDOWS
|
||||||
this.timerThread.Priority = ThreadPriority.Highest;
|
|
||||||
#elif !XBOX360 && !WINDOWS_PHONE
|
|
||||||
this.timerThread.Priority = ThreadPriority.Highest;
|
this.timerThread.Priority = ThreadPriority.Highest;
|
||||||
#endif
|
#endif
|
||||||
this.timerThread.IsBackground = true;
|
this.timerThread.IsBackground = true;
|
||||||
|
@ -147,7 +145,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
// a lot of time given that it doesn't do any real work), forcefully abort
|
// a lot of time given that it doesn't do any real work), forcefully abort
|
||||||
// the thread. This may risk some leaks, but it's the only thing we can do.
|
// the thread. This may risk some leaks, but it's the only thing we can do.
|
||||||
bool success = this.timerThread.Join(2500);
|
bool success = this.timerThread.Join(2500);
|
||||||
#if !XBOX360 && !WINDOWS_PHONE
|
#if WINDOWS
|
||||||
Trace.Assert(success, "Scheduler timer thread did not exit in time");
|
Trace.Assert(success, "Scheduler timer thread did not exit in time");
|
||||||
#endif
|
#endif
|
||||||
// Unsubscribe from the time source to avoid surprise events during or
|
// Unsubscribe from the time source to avoid surprise events during or
|
||||||
|
|
|
@ -20,7 +20,7 @@ License along with this library
|
||||||
|
|
||||||
#if UNITTEST
|
#if UNITTEST
|
||||||
|
|
||||||
#if !XBOX360
|
#if WINDOWS
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -159,6 +159,6 @@ namespace Nuclex.Support.Scheduling {
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Scheduling
|
} // namespace Nuclex.Support.Scheduling
|
||||||
|
|
||||||
#endif // !XBOX360
|
#endif // WINDOWS
|
||||||
|
|
||||||
#endif // UNITTEST
|
#endif // UNITTEST
|
||||||
|
|
|
@ -65,13 +65,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
/// True if the WaitHandle was signalled, false if the timeout was reached
|
/// True if the WaitHandle was signalled, false if the timeout was reached
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override bool WaitOne(AutoResetEvent waitHandle, long ticks) {
|
public override bool WaitOne(AutoResetEvent waitHandle, long ticks) {
|
||||||
#if XNA_3
|
|
||||||
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond), false);
|
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond), false);
|
||||||
#elif XBOX360 || WINDOWS_PHONE
|
|
||||||
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond));
|
|
||||||
#else
|
|
||||||
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond), false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -86,7 +80,7 @@ namespace Nuclex.Support.Scheduling {
|
||||||
/// <summary>Delegate for the timeChanged() callback method</summary>
|
/// <summary>Delegate for the timeChanged() callback method</summary>
|
||||||
private EventHandler onDateTimeAdjustedDelegate;
|
private EventHandler onDateTimeAdjustedDelegate;
|
||||||
|
|
||||||
#endif // !XBOX360
|
#endif // !NO_SYSTEMEVENTS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,11 +97,7 @@ namespace Nuclex.Support {
|
||||||
/// </param>
|
/// </param>
|
||||||
protected override void Dispose(bool explicitDisposing) {
|
protected override void Dispose(bool explicitDisposing) {
|
||||||
if(this.manualResetEvent != null) {
|
if(this.manualResetEvent != null) {
|
||||||
#if XBOX360 && XNA_3
|
|
||||||
base.Handle = IntPtr.Zero;
|
|
||||||
#else
|
|
||||||
base.SafeWaitHandle = null;
|
base.SafeWaitHandle = null;
|
||||||
#endif
|
|
||||||
|
|
||||||
this.manualResetEvent.Close();
|
this.manualResetEvent.Close();
|
||||||
this.manualResetEvent = null;
|
this.manualResetEvent = null;
|
||||||
|
@ -180,8 +176,6 @@ namespace Nuclex.Support {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(XNA_3 && XBOX360)
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Waits for the resource to become available and locks it
|
/// Waits for the resource to become available and locks it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -215,8 +209,6 @@ namespace Nuclex.Support {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !(XNA_3 && XBOX360)
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases a lock on the resource. Note that for a reverse counting semaphore,
|
/// Releases a lock on the resource. Note that for a reverse counting semaphore,
|
||||||
/// it is legal to Release() the resource before locking it.
|
/// it is legal to Release() the resource before locking it.
|
||||||
|
@ -234,11 +226,7 @@ namespace Nuclex.Support {
|
||||||
/// <summary>Creates the event used to make threads wait for the resource</summary>
|
/// <summary>Creates the event used to make threads wait for the resource</summary>
|
||||||
private void createEvent() {
|
private void createEvent() {
|
||||||
this.manualResetEvent = new ManualResetEvent(false);
|
this.manualResetEvent = new ManualResetEvent(false);
|
||||||
#if XBOX360 && XNA_3
|
|
||||||
base.Handle = this.manualResetEvent.Handle;
|
|
||||||
#else
|
|
||||||
base.SafeWaitHandle = this.manualResetEvent.SafeWaitHandle;
|
base.SafeWaitHandle = this.manualResetEvent.SafeWaitHandle;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Event used to make threads wait if the semaphore is full</summary>
|
/// <summary>Event used to make threads wait if the semaphore is full</summary>
|
||||||
|
|
|
@ -26,7 +26,7 @@ using System.Reflection;
|
||||||
|
|
||||||
namespace Nuclex.Support.Services {
|
namespace Nuclex.Support.Services {
|
||||||
|
|
||||||
#if !XBOX360
|
#if WINDOWS
|
||||||
|
|
||||||
/// <summary>Lists the types of all assemblies in an application domain</summary>
|
/// <summary>Lists the types of all assemblies in an application domain</summary>
|
||||||
public class AppDomainTypeLister : MultiAssemblyTypeLister {
|
public class AppDomainTypeLister : MultiAssemblyTypeLister {
|
||||||
|
@ -56,7 +56,7 @@ namespace Nuclex.Support.Services {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !XBOX360
|
#endif // WINDOWS
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Services
|
} // namespace Nuclex.Support.Services
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace Nuclex.Support.Services {
|
||||||
|
|
||||||
#endregion // class Contract
|
#endregion // class Contract
|
||||||
|
|
||||||
#if !XBOX360
|
#if WINDOWS
|
||||||
|
|
||||||
/// <summary>Initializes a new service manager</summary>
|
/// <summary>Initializes a new service manager</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
@ -154,7 +154,7 @@ namespace Nuclex.Support.Services {
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public ServiceManager() : this(new AppDomainTypeLister()) { }
|
public ServiceManager() : this(new AppDomainTypeLister()) { }
|
||||||
|
|
||||||
#endif // !XBOX360
|
#endif // WINDOWS
|
||||||
|
|
||||||
/// <summary>Initializes a new service manager</summary>
|
/// <summary>Initializes a new service manager</summary>
|
||||||
/// <param name="typeLister">
|
/// <param name="typeLister">
|
||||||
|
|
|
@ -299,12 +299,12 @@ namespace Nuclex.Support {
|
||||||
/// <param name="builder">String builder the number will be appended to</param>
|
/// <param name="builder">String builder the number will be appended to</param>
|
||||||
/// <param name="remaining">Remaining digits that will be recursively processed</param>
|
/// <param name="remaining">Remaining digits that will be recursively processed</param>
|
||||||
private static void recursiveAppend(StringBuilder builder, int remaining) {
|
private static void recursiveAppend(StringBuilder builder, int remaining) {
|
||||||
#if XBOX360 || WINDOWS_PHONE
|
#if WINDOWS
|
||||||
int digit = remaining % 10;
|
|
||||||
int tenth = remaining / 10;
|
|
||||||
#else
|
|
||||||
int digit;
|
int digit;
|
||||||
int tenth = Math.DivRem(remaining, 10, out digit);
|
int tenth = Math.DivRem(remaining, 10, out digit);
|
||||||
|
#else
|
||||||
|
int digit = remaining % 10;
|
||||||
|
int tenth = remaining / 10;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tenth > 0) {
|
if (tenth > 0) {
|
||||||
|
@ -318,12 +318,12 @@ namespace Nuclex.Support {
|
||||||
/// <param name="builder">String builder the number will be appended to</param>
|
/// <param name="builder">String builder the number will be appended to</param>
|
||||||
/// <param name="remaining">Remaining digits that will be recursively processed</param>
|
/// <param name="remaining">Remaining digits that will be recursively processed</param>
|
||||||
private static void recursiveAppend(StringBuilder builder, long remaining) {
|
private static void recursiveAppend(StringBuilder builder, long remaining) {
|
||||||
#if XBOX360 || WINDOWS_PHONE
|
#if WINDOWS
|
||||||
long digit = remaining % 10;
|
|
||||||
long tenth = remaining / 10;
|
|
||||||
#else
|
|
||||||
long digit;
|
long digit;
|
||||||
long tenth = Math.DivRem(remaining, 10, out digit);
|
long tenth = Math.DivRem(remaining, 10, out digit);
|
||||||
|
#else
|
||||||
|
long digit = remaining % 10;
|
||||||
|
long tenth = remaining / 10;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tenth > 0) {
|
if (tenth > 0) {
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace Nuclex.Support.Tracking {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !XBOX360 && !WINDOWS_PHONE
|
#if WINDOWS
|
||||||
|
|
||||||
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
||||||
/// <param name="timeout">
|
/// <param name="timeout">
|
||||||
|
@ -150,7 +150,7 @@ namespace Nuclex.Support.Tracking {
|
||||||
return WaitHandle.WaitOne(timeout, false);
|
return WaitHandle.WaitOne(timeout, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !XBOX360
|
#endif // WINDOWS
|
||||||
|
|
||||||
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
||||||
/// <param name="timeoutMilliseconds">
|
/// <param name="timeoutMilliseconds">
|
||||||
|
@ -164,13 +164,7 @@ namespace Nuclex.Support.Tracking {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if XNA_3
|
|
||||||
return WaitHandle.WaitOne(timeoutMilliseconds, false);
|
return WaitHandle.WaitOne(timeoutMilliseconds, false);
|
||||||
#elif XBOX360 || WINDOWS_PHONE
|
|
||||||
return WaitHandle.WaitOne(timeoutMilliseconds);
|
|
||||||
#else
|
|
||||||
return WaitHandle.WaitOne(timeoutMilliseconds, false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Whether the transaction has ended already</summary>
|
/// <summary>Whether the transaction has ended already</summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user