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:
Markus Ewald 2010-12-24 01:02:56 +00:00
parent 645148a751
commit 46cbc920b1
16 changed files with 75 additions and 110 deletions

View File

@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\net-4.0\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;UNITTEST</DefineConstants>
<DefineConstants>TRACE;DEBUG;UNITTEST;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\net-4.0\Debug\Nuclex.Support.xml</DocumentationFile>
@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\net-4.0\Release\</OutputPath>
<DefineConstants>TRACE;UNITTEST</DefineConstants>
<DefineConstants>TRACE;UNITTEST;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\net-4.0\Release\Nuclex.Support.xml</DocumentationFile>

View File

@ -197,7 +197,7 @@ namespace Nuclex.Support {
// explicitly move it to that core. MSDN states that SetProcessorAffinity() should
// be called from the thread whose affinity is being changed.
Thread.CurrentThread.SetProcessorAffinity(new int[] { hardwareThreadIndex });
#elif !WINDOWS_PHONE
#elif WINDOWS
if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
// Prevent this managed thread from impersonating another system thread.
// 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>
/// <returns>The ProcessThread for the calling thread</returns>
internal static ProcessThread GetProcessThread(int threadId) {
@ -282,7 +282,7 @@ namespace Nuclex.Support {
/// <summary>Delegate used to handle assertion checks in the code</summary>
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>
/// <returns>The thread is of the calling thread</returns>
[DllImport("kernel32.dll")]

View File

@ -294,11 +294,11 @@ namespace Nuclex.Support.Collections {
}
index += this.firstBlockStartIndex;
#if XBOX360 || WINDOWS_PHONE
#if WINDOWS
blockIndex = Math.DivRem(index, this.blockSize, out subIndex);
#else
blockIndex = index / this.blockSize;
subIndex = index % this.blockSize;
#else
blockIndex = Math.DivRem(index, this.blockSize, out subIndex);
#endif
}

View File

@ -28,8 +28,6 @@ using NUnit.Framework;
namespace Nuclex.Support.Plugins {
#if XBOX360
/// <summary>Unit Test for the assembly load event argument container</summary>
[TestFixture]
public class AssemblyLoadEventArgsTest {
@ -48,8 +46,6 @@ namespace Nuclex.Support.Plugins {
}
#endif // XBOX360
} // namespace Nuclex.Support.Plugins
#endif // UNITTEST

View File

@ -52,6 +52,6 @@ namespace Nuclex.Support.Plugins {
}
#endif // XBOX360
#endif // XBOX360 || WINDOWS_PHONE
} // namespace Nuclex.Support.Plugins

View File

@ -121,7 +121,7 @@ namespace Nuclex.Support.Plugins {
/// <summary>Reports an error to the debugging console</summary>
/// <param name="error">Error message that will be reported</param>
private static void reportError(string error) {
#if !XBOX360 && !WINDOWS_PHONE
#if WINDOWS
Trace.WriteLine(error);
#endif
}

View File

@ -66,7 +66,7 @@ namespace Nuclex.Support.Plugins {
loadedAssembly = LoadAssemblyFromFile(path);
return true;
}
#if !XBOX360
#if WINDOWS
// 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
catch(DllNotFoundException) {
@ -178,7 +178,7 @@ namespace Nuclex.Support.Plugins {
/// <summary>Reports an error to the debugging console</summary>
/// <param name="error">Error message that will be reported</param>
private static void reportError(string error) {
#if !XBOX360 && !WINDOWS_PHONE
#if WINDOWS
Trace.WriteLine(error);
#endif
}

View File

@ -92,13 +92,8 @@ namespace Nuclex.Support.Scheduling {
// 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
int milliseconds = (int)(ticks / TicksPerMillisecond);
#if XNA_3
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.
checkForTimeAdjustment();

View File

@ -128,9 +128,7 @@ namespace Nuclex.Support.Scheduling {
this.timerThread = new Thread(new ThreadStart(runTimerThread));
this.timerThread.Name = "Nuclex.Support.Scheduling.Scheduler";
#if XNA_3
this.timerThread.Priority = ThreadPriority.Highest;
#elif !XBOX360 && !WINDOWS_PHONE
#if WINDOWS
this.timerThread.Priority = ThreadPriority.Highest;
#endif
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
// the thread. This may risk some leaks, but it's the only thing we can do.
bool success = this.timerThread.Join(2500);
#if !XBOX360 && !WINDOWS_PHONE
#if WINDOWS
Trace.Assert(success, "Scheduler timer thread did not exit in time");
#endif
// Unsubscribe from the time source to avoid surprise events during or

View File

@ -20,7 +20,7 @@ License along with this library
#if UNITTEST
#if !XBOX360
#if WINDOWS
using System;
using System.Collections.Generic;
@ -159,6 +159,6 @@ namespace Nuclex.Support.Scheduling {
} // namespace Nuclex.Support.Scheduling
#endif // !XBOX360
#endif // WINDOWS
#endif // UNITTEST

View File

@ -65,13 +65,7 @@ namespace Nuclex.Support.Scheduling {
/// True if the WaitHandle was signalled, false if the timeout was reached
/// </returns>
public override bool WaitOne(AutoResetEvent waitHandle, long ticks) {
#if XNA_3
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>
@ -86,7 +80,7 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Delegate for the timeChanged() callback method</summary>
private EventHandler onDateTimeAdjustedDelegate;
#endif // !XBOX360
#endif // !NO_SYSTEMEVENTS
}

View File

@ -97,11 +97,7 @@ namespace Nuclex.Support {
/// </param>
protected override void Dispose(bool explicitDisposing) {
if(this.manualResetEvent != null) {
#if XBOX360 && XNA_3
base.Handle = IntPtr.Zero;
#else
base.SafeWaitHandle = null;
#endif
this.manualResetEvent.Close();
this.manualResetEvent = null;
@ -180,8 +176,6 @@ namespace Nuclex.Support {
#endif
}
#if !(XNA_3 && XBOX360)
/// <summary>
/// Waits for the resource to become available and locks it
/// </summary>
@ -215,8 +209,6 @@ namespace Nuclex.Support {
#endif
}
#endif // !(XNA_3 && XBOX360)
/// <summary>
/// Releases a lock on the resource. Note that for a reverse counting semaphore,
/// 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>
private void createEvent() {
this.manualResetEvent = new ManualResetEvent(false);
#if XBOX360 && XNA_3
base.Handle = this.manualResetEvent.Handle;
#else
base.SafeWaitHandle = this.manualResetEvent.SafeWaitHandle;
#endif
}
/// <summary>Event used to make threads wait if the semaphore is full</summary>

View File

@ -26,7 +26,7 @@ using System.Reflection;
namespace Nuclex.Support.Services {
#if !XBOX360
#if WINDOWS
/// <summary>Lists the types of all assemblies in an application domain</summary>
public class AppDomainTypeLister : MultiAssemblyTypeLister {
@ -56,7 +56,7 @@ namespace Nuclex.Support.Services {
}
#endif // !XBOX360
#endif // WINDOWS
} // namespace Nuclex.Support.Services

View File

@ -144,7 +144,7 @@ namespace Nuclex.Support.Services {
#endregion // class Contract
#if !XBOX360
#if WINDOWS
/// <summary>Initializes a new service manager</summary>
/// <remarks>
@ -154,7 +154,7 @@ namespace Nuclex.Support.Services {
/// </remarks>
public ServiceManager() : this(new AppDomainTypeLister()) { }
#endif // !XBOX360
#endif // WINDOWS
/// <summary>Initializes a new service manager</summary>
/// <param name="typeLister">

View File

@ -299,12 +299,12 @@ namespace Nuclex.Support {
/// <param name="builder">String builder the number will be appended to</param>
/// <param name="remaining">Remaining digits that will be recursively processed</param>
private static void recursiveAppend(StringBuilder builder, int remaining) {
#if XBOX360 || WINDOWS_PHONE
int digit = remaining % 10;
int tenth = remaining / 10;
#else
#if WINDOWS
int digit;
int tenth = Math.DivRem(remaining, 10, out digit);
#else
int digit = remaining % 10;
int tenth = remaining / 10;
#endif
if (tenth > 0) {
@ -318,12 +318,12 @@ namespace Nuclex.Support {
/// <param name="builder">String builder the number will be appended to</param>
/// <param name="remaining">Remaining digits that will be recursively processed</param>
private static void recursiveAppend(StringBuilder builder, long remaining) {
#if XBOX360 || WINDOWS_PHONE
long digit = remaining % 10;
long tenth = remaining / 10;
#else
#if WINDOWS
long digit;
long tenth = Math.DivRem(remaining, 10, out digit);
#else
long digit = remaining % 10;
long tenth = remaining / 10;
#endif
if (tenth > 0) {

View File

@ -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>
/// <param name="timeout">
@ -150,7 +150,7 @@ namespace Nuclex.Support.Tracking {
return WaitHandle.WaitOne(timeout, false);
}
#endif // !XBOX360
#endif // WINDOWS
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
/// <param name="timeoutMilliseconds">
@ -164,13 +164,7 @@ namespace Nuclex.Support.Tracking {
return true;
}
#if XNA_3
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>