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> <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>

View File

@ -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")]

View File

@ -68,7 +68,7 @@ namespace Nuclex.Support.Collections {
#if DEBUG #if DEBUG
checkVersion(); checkVersion();
#endif #endif
if(this.currentBlock == null) { if (this.currentBlock == null) {
throw new InvalidOperationException("Enumerator is not on a valid position"); throw new InvalidOperationException("Enumerator is not on a valid position");
} }
@ -85,15 +85,15 @@ namespace Nuclex.Support.Collections {
#endif #endif
// If we haven't reached the last block yet // If we haven't reached the last block yet
if(this.currentBlockIndex < this.lastBlock) { if (this.currentBlockIndex < this.lastBlock) {
// Advance to the next item. If the end of the current block is reached, // Advance to the next item. If the end of the current block is reached,
// go to the next block's first item // go to the next block's first item
++this.subIndex; ++this.subIndex;
if(this.subIndex >= this.blockSize) { if (this.subIndex >= this.blockSize) {
++this.currentBlockIndex; ++this.currentBlockIndex;
this.currentBlock = this.deque.blocks[this.currentBlockIndex]; this.currentBlock = this.deque.blocks[this.currentBlockIndex];
if(this.currentBlockIndex == 0) { if (this.currentBlockIndex == 0) {
this.subIndex = this.deque.firstBlockStartIndex; this.subIndex = this.deque.firstBlockStartIndex;
} else { } else {
this.subIndex = 0; this.subIndex = 0;
@ -107,7 +107,7 @@ namespace Nuclex.Support.Collections {
} else { // We in or beyond the last block } else { // We in or beyond the last block
// Are there any items left to advance to? // Are there any items left to advance to?
if(this.subIndex < this.lastBlockEndIndex) { if (this.subIndex < this.lastBlockEndIndex) {
++this.subIndex; ++this.subIndex;
return true; return true;
} else { // Nope, we've reached the end of the deque } else { // Nope, we've reached the end of the deque
@ -203,7 +203,7 @@ namespace Nuclex.Support.Collections {
/// <summary>The first item in the double-ended queue</summary> /// <summary>The first item in the double-ended queue</summary>
public ItemType First { public ItemType First {
get { get {
if(this.count == 0) { if (this.count == 0) {
throw new InvalidOperationException("The deque is empty"); throw new InvalidOperationException("The deque is empty");
} }
return this.blocks[0][this.firstBlockStartIndex]; return this.blocks[0][this.firstBlockStartIndex];
@ -213,7 +213,7 @@ namespace Nuclex.Support.Collections {
/// <summary>The last item in the double-ended queue</summary> /// <summary>The last item in the double-ended queue</summary>
public ItemType Last { public ItemType Last {
get { get {
if(this.count == 0) { if (this.count == 0) {
throw new InvalidOperationException("The deque is empty"); throw new InvalidOperationException("The deque is empty");
} }
return this.blocks[this.blocks.Count - 1][this.lastBlockEndIndex - 1]; return this.blocks[this.blocks.Count - 1][this.lastBlockEndIndex - 1];
@ -231,13 +231,13 @@ namespace Nuclex.Support.Collections {
/// <param name="array">Array the contents of the deque will be copied into</param> /// <param name="array">Array the contents of the deque will be copied into</param>
/// <param name="arrayIndex">Array index the deque contents will begin at</param> /// <param name="arrayIndex">Array index the deque contents will begin at</param>
public void CopyTo(ItemType[] array, int arrayIndex) { public void CopyTo(ItemType[] array, int arrayIndex) {
if(this.count > (array.Length - arrayIndex)) { if (this.count > (array.Length - arrayIndex)) {
throw new ArgumentException( throw new ArgumentException(
"Array too small to hold the collection items starting at the specified index" "Array too small to hold the collection items starting at the specified index"
); );
} }
if(this.blocks.Count == 1) { // Does only one block exist? if (this.blocks.Count == 1) { // Does only one block exist?
// Copy the one and only block there is // Copy the one and only block there is
Array.Copy( Array.Copy(
@ -259,7 +259,7 @@ namespace Nuclex.Support.Collections {
// Copy all intermediate blocks (if there are any). These are completely filled // Copy all intermediate blocks (if there are any). These are completely filled
int lastBlock = this.blocks.Count - 1; int lastBlock = this.blocks.Count - 1;
for(int index = 1; index < lastBlock; ++index) { for (int index = 1; index < lastBlock; ++index) {
Array.Copy( Array.Copy(
this.blocks[index], 0, this.blocks[index], 0,
array, arrayIndex, array, arrayIndex,
@ -289,16 +289,16 @@ namespace Nuclex.Support.Collections {
/// <param name="blockIndex">Index of the block the entry is contained in</param> /// <param name="blockIndex">Index of the block the entry is contained in</param>
/// <param name="subIndex">Local sub index of the entry within the block</param> /// <param name="subIndex">Local sub index of the entry within the block</param>
private void findIndex(int index, out int blockIndex, out int subIndex) { private void findIndex(int index, out int blockIndex, out int subIndex) {
if((index < 0) || (index >= this.count)) { if ((index < 0) || (index >= this.count)) {
throw new ArgumentOutOfRangeException("Index out of range", "index"); throw new ArgumentOutOfRangeException("Index out of range", "index");
} }
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
} }
@ -314,7 +314,7 @@ namespace Nuclex.Support.Collections {
/// <summary>Verifies that the provided object matches the deque's type</summary> /// <summary>Verifies that the provided object matches the deque's type</summary>
/// <param name="value">Value that will be checked for compatibility</param> /// <param name="value">Value that will be checked for compatibility</param>
private static void verifyCompatibleObject(object value) { private static void verifyCompatibleObject(object value) {
if(!isCompatibleObject(value)) { if (!isCompatibleObject(value)) {
throw new ArgumentException("Value does not match the deque's type", "value"); throw new ArgumentException("Value does not match the deque's type", "value");
} }
} }

View File

@ -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

View File

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

View File

@ -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
} }

View File

@ -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
} }

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 // 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();

View File

@ -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

View File

@ -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

View File

@ -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
} }

View File

@ -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>

View File

@ -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

View File

@ -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">

View File

@ -25,12 +25,12 @@ using System.Text;
namespace Nuclex.Support { namespace Nuclex.Support {
/* /*
public enum Garbage { public enum Garbage {
Avoid, Avoid,
Accept Accept
} }
*/ */
/// <summary>Contains helper methods for the string builder class</summary> /// <summary>Contains helper methods for the string builder class</summary>
public static class StringBuilderHelper { public static class StringBuilderHelper {
@ -70,7 +70,7 @@ namespace Nuclex.Support {
/// with a small performance impact compared to the built-in method. /// with a small performance impact compared to the built-in method.
/// </remarks> /// </remarks>
public static void Append(StringBuilder builder, int value) { public static void Append(StringBuilder builder, int value) {
if(value < 0) { if (value < 0) {
builder.Append('-'); builder.Append('-');
recursiveAppend(builder, -value); recursiveAppend(builder, -value);
} else { } else {
@ -89,7 +89,7 @@ namespace Nuclex.Support {
/// with a small performance impact compared to the built-in method. /// with a small performance impact compared to the built-in method.
/// </remarks> /// </remarks>
public static void Append(StringBuilder builder, long value) { public static void Append(StringBuilder builder, long value) {
if(value < 0) { if (value < 0) {
builder.Append('-'); builder.Append('-');
recursiveAppend(builder, -value); recursiveAppend(builder, -value);
} else { } else {
@ -142,9 +142,9 @@ namespace Nuclex.Support {
int integral; int integral;
int fractional; int fractional;
if(exponent >= 0) { if (exponent >= 0) {
if(exponent >= FractionalBitCount) { if (exponent >= FractionalBitCount) {
if(exponent >= NumericBitCount) { if (exponent >= NumericBitCount) {
return false; return false;
} }
integral = mantissa << (exponent - FractionalBitCount); integral = mantissa << (exponent - FractionalBitCount);
@ -154,7 +154,7 @@ namespace Nuclex.Support {
fractional = (mantissa << (exponent + 1)) & FractionalBits; fractional = (mantissa << (exponent + 1)) & FractionalBits;
} }
} else { } else {
if(exponent < -FractionalBitCount) { if (exponent < -FractionalBitCount) {
return false; return false;
} }
integral = 0; integral = 0;
@ -162,30 +162,30 @@ namespace Nuclex.Support {
} }
// Build the integral part // Build the integral part
if(intValue < 0) { if (intValue < 0) {
builder.Append('-'); builder.Append('-');
} }
if(integral == 0) { if (integral == 0) {
builder.Append('0'); builder.Append('0');
} else { } else {
recursiveAppend(builder, integral); recursiveAppend(builder, integral);
} }
if(decimalPlaces > 0) { if (decimalPlaces > 0) {
builder.Append('.'); builder.Append('.');
// Build the fractional part // Build the fractional part
if(fractional == 0) { if (fractional == 0) {
builder.Append('0'); builder.Append('0');
} else { } else {
while(fractional != 0) { while (fractional != 0) {
fractional *= 10; fractional *= 10;
int digit = (fractional >> FractionalBitCountPlusOne); int digit = (fractional >> FractionalBitCountPlusOne);
builder.Append(numbers[digit]); builder.Append(numbers[digit]);
fractional &= FractionalBits; fractional &= FractionalBits;
--decimalPlaces; --decimalPlaces;
if(decimalPlaces == 0) { if (decimalPlaces == 0) {
break; break;
} }
} }
@ -242,9 +242,9 @@ namespace Nuclex.Support {
long integral; long integral;
long fractional; long fractional;
if(exponent >= 0) { if (exponent >= 0) {
if(exponent >= FractionalBitCount) { if (exponent >= FractionalBitCount) {
if(exponent >= NumericBitCount) { if (exponent >= NumericBitCount) {
return false; return false;
} }
integral = mantissa << (int)(exponent - FractionalBitCount); integral = mantissa << (int)(exponent - FractionalBitCount);
@ -254,7 +254,7 @@ namespace Nuclex.Support {
fractional = (mantissa << (int)(exponent + 1)) & FractionalBits; fractional = (mantissa << (int)(exponent + 1)) & FractionalBits;
} }
} else { } else {
if(exponent < -FractionalBitCount) { if (exponent < -FractionalBitCount) {
return false; return false;
} }
integral = 0; integral = 0;
@ -262,30 +262,30 @@ namespace Nuclex.Support {
} }
// Build the integral part // Build the integral part
if(longValue < 0) { if (longValue < 0) {
builder.Append('-'); builder.Append('-');
} }
if(integral == 0) { if (integral == 0) {
builder.Append('0'); builder.Append('0');
} else { } else {
recursiveAppend(builder, integral); recursiveAppend(builder, integral);
} }
if(decimalPlaces > 0) { if (decimalPlaces > 0) {
builder.Append('.'); builder.Append('.');
// Build the fractional part // Build the fractional part
if(fractional == 0) { if (fractional == 0) {
builder.Append('0'); builder.Append('0');
} else { } else {
while(fractional != 0) { while (fractional != 0) {
fractional *= 10; fractional *= 10;
long digit = (fractional >> FractionalBitCountPlusOne); long digit = (fractional >> FractionalBitCountPlusOne);
builder.Append(numbers[digit]); builder.Append(numbers[digit]);
fractional &= FractionalBits; fractional &= FractionalBits;
--decimalPlaces; --decimalPlaces;
if(decimalPlaces == 0) { if (decimalPlaces == 0) {
break; break;
} }
} }
@ -299,15 +299,15 @@ 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) {
recursiveAppend(builder, tenth); recursiveAppend(builder, tenth);
} }
@ -318,15 +318,15 @@ 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) {
recursiveAppend(builder, tenth); recursiveAppend(builder, tenth);
} }

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> /// <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>