diff --git a/Nuclex.Support (net-4.0).csproj b/Nuclex.Support (net-4.0).csproj index 2a14ac7..f6bf83d 100644 --- a/Nuclex.Support (net-4.0).csproj +++ b/Nuclex.Support (net-4.0).csproj @@ -19,7 +19,7 @@ full false bin\net-4.0\Debug\ - TRACE;DEBUG;UNITTEST + TRACE;DEBUG;UNITTEST;WINDOWS prompt 4 bin\net-4.0\Debug\Nuclex.Support.xml @@ -28,7 +28,7 @@ pdbonly true bin\net-4.0\Release\ - TRACE;UNITTEST + TRACE;UNITTEST;WINDOWS prompt 4 bin\net-4.0\Release\Nuclex.Support.xml diff --git a/Source/AffineThreadPool.cs b/Source/AffineThreadPool.cs index 6511ab6..767f4d1 100644 --- a/Source/AffineThreadPool.cs +++ b/Source/AffineThreadPool.cs @@ -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 /// Retrieves the ProcessThread for the calling thread /// The ProcessThread for the calling thread internal static ProcessThread GetProcessThread(int threadId) { @@ -282,7 +282,7 @@ namespace Nuclex.Support { /// Delegate used to handle assertion checks in the code public static volatile ExceptionDelegate ExceptionHandler = DefaultExceptionHandler; -#if !XBOX360 // Only called if platform is Win32NT +#if WINDOWS /// Retrieves the calling thread's thread id /// The thread is of the calling thread [DllImport("kernel32.dll")] diff --git a/Source/Collections/Deque.cs b/Source/Collections/Deque.cs index ffe3687..513631c 100644 --- a/Source/Collections/Deque.cs +++ b/Source/Collections/Deque.cs @@ -68,7 +68,7 @@ namespace Nuclex.Support.Collections { #if DEBUG checkVersion(); #endif - if(this.currentBlock == null) { + if (this.currentBlock == null) { throw new InvalidOperationException("Enumerator is not on a valid position"); } @@ -85,15 +85,15 @@ namespace Nuclex.Support.Collections { #endif // 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, // go to the next block's first item ++this.subIndex; - if(this.subIndex >= this.blockSize) { + if (this.subIndex >= this.blockSize) { ++this.currentBlockIndex; this.currentBlock = this.deque.blocks[this.currentBlockIndex]; - if(this.currentBlockIndex == 0) { + if (this.currentBlockIndex == 0) { this.subIndex = this.deque.firstBlockStartIndex; } else { this.subIndex = 0; @@ -107,7 +107,7 @@ namespace Nuclex.Support.Collections { } else { // We in or beyond the last block // Are there any items left to advance to? - if(this.subIndex < this.lastBlockEndIndex) { + if (this.subIndex < this.lastBlockEndIndex) { ++this.subIndex; return true; } else { // Nope, we've reached the end of the deque @@ -203,7 +203,7 @@ namespace Nuclex.Support.Collections { /// The first item in the double-ended queue public ItemType First { get { - if(this.count == 0) { + if (this.count == 0) { throw new InvalidOperationException("The deque is empty"); } return this.blocks[0][this.firstBlockStartIndex]; @@ -213,7 +213,7 @@ namespace Nuclex.Support.Collections { /// The last item in the double-ended queue public ItemType Last { get { - if(this.count == 0) { + if (this.count == 0) { throw new InvalidOperationException("The deque is empty"); } return this.blocks[this.blocks.Count - 1][this.lastBlockEndIndex - 1]; @@ -231,13 +231,13 @@ namespace Nuclex.Support.Collections { /// Array the contents of the deque will be copied into /// Array index the deque contents will begin at public void CopyTo(ItemType[] array, int arrayIndex) { - if(this.count > (array.Length - arrayIndex)) { + if (this.count > (array.Length - arrayIndex)) { throw new ArgumentException( "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 Array.Copy( @@ -259,7 +259,7 @@ namespace Nuclex.Support.Collections { // Copy all intermediate blocks (if there are any). These are completely filled int lastBlock = this.blocks.Count - 1; - for(int index = 1; index < lastBlock; ++index) { + for (int index = 1; index < lastBlock; ++index) { Array.Copy( this.blocks[index], 0, array, arrayIndex, @@ -289,16 +289,16 @@ namespace Nuclex.Support.Collections { /// Index of the block the entry is contained in /// Local sub index of the entry within the block 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"); } 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 } @@ -314,7 +314,7 @@ namespace Nuclex.Support.Collections { /// Verifies that the provided object matches the deque's type /// Value that will be checked for compatibility private static void verifyCompatibleObject(object value) { - if(!isCompatibleObject(value)) { + if (!isCompatibleObject(value)) { throw new ArgumentException("Value does not match the deque's type", "value"); } } diff --git a/Source/Plugins/AssemblyLoadEventArgs.Test.cs b/Source/Plugins/AssemblyLoadEventArgs.Test.cs index 6ee65a5..246ca29 100644 --- a/Source/Plugins/AssemblyLoadEventArgs.Test.cs +++ b/Source/Plugins/AssemblyLoadEventArgs.Test.cs @@ -28,8 +28,6 @@ using NUnit.Framework; namespace Nuclex.Support.Plugins { -#if XBOX360 - /// Unit Test for the assembly load event argument container [TestFixture] public class AssemblyLoadEventArgsTest { @@ -48,8 +46,6 @@ namespace Nuclex.Support.Plugins { } -#endif // XBOX360 - } // namespace Nuclex.Support.Plugins #endif // UNITTEST diff --git a/Source/Plugins/AssemblyLoadEventArgs.cs b/Source/Plugins/AssemblyLoadEventArgs.cs index 8fd7c69..3111600 100644 --- a/Source/Plugins/AssemblyLoadEventArgs.cs +++ b/Source/Plugins/AssemblyLoadEventArgs.cs @@ -52,6 +52,6 @@ namespace Nuclex.Support.Plugins { } -#endif // XBOX360 +#endif // XBOX360 || WINDOWS_PHONE } // namespace Nuclex.Support.Plugins diff --git a/Source/Plugins/PluginHost.cs b/Source/Plugins/PluginHost.cs index beb0c1e..5042c31 100644 --- a/Source/Plugins/PluginHost.cs +++ b/Source/Plugins/PluginHost.cs @@ -121,7 +121,7 @@ namespace Nuclex.Support.Plugins { /// Reports an error to the debugging console /// Error message that will be reported private static void reportError(string error) { -#if !XBOX360 && !WINDOWS_PHONE +#if WINDOWS Trace.WriteLine(error); #endif } diff --git a/Source/Plugins/PluginRepository.cs b/Source/Plugins/PluginRepository.cs index 50a5ec3..cf82889 100644 --- a/Source/Plugins/PluginRepository.cs +++ b/Source/Plugins/PluginRepository.cs @@ -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 { /// Reports an error to the debugging console /// Error message that will be reported private static void reportError(string error) { -#if !XBOX360 && !WINDOWS_PHONE +#if WINDOWS Trace.WriteLine(error); #endif } diff --git a/Source/Scheduling/GenericTimeSource.cs b/Source/Scheduling/GenericTimeSource.cs index da35e8c..cdea585 100644 --- a/Source/Scheduling/GenericTimeSource.cs +++ b/Source/Scheduling/GenericTimeSource.cs @@ -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(); diff --git a/Source/Scheduling/Scheduler.cs b/Source/Scheduling/Scheduler.cs index 4d3b6fc..5fb30c3 100644 --- a/Source/Scheduling/Scheduler.cs +++ b/Source/Scheduling/Scheduler.cs @@ -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 diff --git a/Source/Scheduling/WindowsTimeSource.Test.cs b/Source/Scheduling/WindowsTimeSource.Test.cs index 911caca..7ef272e 100644 --- a/Source/Scheduling/WindowsTimeSource.Test.cs +++ b/Source/Scheduling/WindowsTimeSource.Test.cs @@ -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 diff --git a/Source/Scheduling/WindowsTimeSource.cs b/Source/Scheduling/WindowsTimeSource.cs index 9d66346..f3f01f3 100644 --- a/Source/Scheduling/WindowsTimeSource.cs +++ b/Source/Scheduling/WindowsTimeSource.cs @@ -65,13 +65,7 @@ namespace Nuclex.Support.Scheduling { /// True if the WaitHandle was signalled, false if the timeout was reached /// 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 } /// @@ -86,7 +80,7 @@ namespace Nuclex.Support.Scheduling { /// Delegate for the timeChanged() callback method private EventHandler onDateTimeAdjustedDelegate; -#endif // !XBOX360 +#endif // !NO_SYSTEMEVENTS } diff --git a/Source/Semaphore.cs b/Source/Semaphore.cs index 25abf55..44d85e2 100644 --- a/Source/Semaphore.cs +++ b/Source/Semaphore.cs @@ -97,11 +97,7 @@ namespace Nuclex.Support { /// 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) - /// /// Waits for the resource to become available and locks it /// @@ -215,8 +209,6 @@ namespace Nuclex.Support { #endif } -#endif // !(XNA_3 && XBOX360) - /// /// 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 { /// Creates the event used to make threads wait for the resource private void createEvent() { this.manualResetEvent = new ManualResetEvent(false); -#if XBOX360 && XNA_3 - base.Handle = this.manualResetEvent.Handle; -#else base.SafeWaitHandle = this.manualResetEvent.SafeWaitHandle; -#endif } /// Event used to make threads wait if the semaphore is full diff --git a/Source/Services/AppDomainTypeLister.cs b/Source/Services/AppDomainTypeLister.cs index 3a592ad..876cbaa 100644 --- a/Source/Services/AppDomainTypeLister.cs +++ b/Source/Services/AppDomainTypeLister.cs @@ -26,7 +26,7 @@ using System.Reflection; namespace Nuclex.Support.Services { -#if !XBOX360 +#if WINDOWS /// Lists the types of all assemblies in an application domain public class AppDomainTypeLister : MultiAssemblyTypeLister { @@ -56,7 +56,7 @@ namespace Nuclex.Support.Services { } -#endif // !XBOX360 +#endif // WINDOWS } // namespace Nuclex.Support.Services diff --git a/Source/Services/ServiceManager.cs b/Source/Services/ServiceManager.cs index a6bc3ce..252e64f 100644 --- a/Source/Services/ServiceManager.cs +++ b/Source/Services/ServiceManager.cs @@ -144,7 +144,7 @@ namespace Nuclex.Support.Services { #endregion // class Contract -#if !XBOX360 +#if WINDOWS /// Initializes a new service manager /// @@ -154,7 +154,7 @@ namespace Nuclex.Support.Services { /// public ServiceManager() : this(new AppDomainTypeLister()) { } -#endif // !XBOX360 +#endif // WINDOWS /// Initializes a new service manager /// diff --git a/Source/StringBuilderHelper.cs b/Source/StringBuilderHelper.cs index 8dace71..471f35a 100644 --- a/Source/StringBuilderHelper.cs +++ b/Source/StringBuilderHelper.cs @@ -25,12 +25,12 @@ using System.Text; namespace Nuclex.Support { -/* - public enum Garbage { - Avoid, - Accept - } -*/ + /* + public enum Garbage { + Avoid, + Accept + } + */ /// Contains helper methods for the string builder class public static class StringBuilderHelper { @@ -70,7 +70,7 @@ namespace Nuclex.Support { /// with a small performance impact compared to the built-in method. /// public static void Append(StringBuilder builder, int value) { - if(value < 0) { + if (value < 0) { builder.Append('-'); recursiveAppend(builder, -value); } else { @@ -89,7 +89,7 @@ namespace Nuclex.Support { /// with a small performance impact compared to the built-in method. /// public static void Append(StringBuilder builder, long value) { - if(value < 0) { + if (value < 0) { builder.Append('-'); recursiveAppend(builder, -value); } else { @@ -142,9 +142,9 @@ namespace Nuclex.Support { int integral; int fractional; - if(exponent >= 0) { - if(exponent >= FractionalBitCount) { - if(exponent >= NumericBitCount) { + if (exponent >= 0) { + if (exponent >= FractionalBitCount) { + if (exponent >= NumericBitCount) { return false; } integral = mantissa << (exponent - FractionalBitCount); @@ -154,7 +154,7 @@ namespace Nuclex.Support { fractional = (mantissa << (exponent + 1)) & FractionalBits; } } else { - if(exponent < -FractionalBitCount) { + if (exponent < -FractionalBitCount) { return false; } integral = 0; @@ -162,30 +162,30 @@ namespace Nuclex.Support { } // Build the integral part - if(intValue < 0) { + if (intValue < 0) { builder.Append('-'); } - if(integral == 0) { + if (integral == 0) { builder.Append('0'); } else { recursiveAppend(builder, integral); } - if(decimalPlaces > 0) { + if (decimalPlaces > 0) { builder.Append('.'); // Build the fractional part - if(fractional == 0) { + if (fractional == 0) { builder.Append('0'); } else { - while(fractional != 0) { + while (fractional != 0) { fractional *= 10; int digit = (fractional >> FractionalBitCountPlusOne); builder.Append(numbers[digit]); fractional &= FractionalBits; - + --decimalPlaces; - if(decimalPlaces == 0) { + if (decimalPlaces == 0) { break; } } @@ -242,9 +242,9 @@ namespace Nuclex.Support { long integral; long fractional; - if(exponent >= 0) { - if(exponent >= FractionalBitCount) { - if(exponent >= NumericBitCount) { + if (exponent >= 0) { + if (exponent >= FractionalBitCount) { + if (exponent >= NumericBitCount) { return false; } integral = mantissa << (int)(exponent - FractionalBitCount); @@ -254,7 +254,7 @@ namespace Nuclex.Support { fractional = (mantissa << (int)(exponent + 1)) & FractionalBits; } } else { - if(exponent < -FractionalBitCount) { + if (exponent < -FractionalBitCount) { return false; } integral = 0; @@ -262,30 +262,30 @@ namespace Nuclex.Support { } // Build the integral part - if(longValue < 0) { + if (longValue < 0) { builder.Append('-'); } - if(integral == 0) { + if (integral == 0) { builder.Append('0'); } else { recursiveAppend(builder, integral); } - if(decimalPlaces > 0) { + if (decimalPlaces > 0) { builder.Append('.'); // Build the fractional part - if(fractional == 0) { + if (fractional == 0) { builder.Append('0'); } else { - while(fractional != 0) { + while (fractional != 0) { fractional *= 10; long digit = (fractional >> FractionalBitCountPlusOne); builder.Append(numbers[digit]); fractional &= FractionalBits; --decimalPlaces; - if(decimalPlaces == 0) { + if (decimalPlaces == 0) { break; } } @@ -299,15 +299,15 @@ namespace Nuclex.Support { /// String builder the number will be appended to /// Remaining digits that will be recursively processed 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) { + if (tenth > 0) { recursiveAppend(builder, tenth); } @@ -318,15 +318,15 @@ namespace Nuclex.Support { /// String builder the number will be appended to /// Remaining digits that will be recursively processed 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) { + if (tenth > 0) { recursiveAppend(builder, tenth); } diff --git a/Source/Tracking/Transaction.cs b/Source/Tracking/Transaction.cs index 2b69109..b77c542 100644 --- a/Source/Tracking/Transaction.cs +++ b/Source/Tracking/Transaction.cs @@ -133,7 +133,7 @@ namespace Nuclex.Support.Tracking { } } -#if !XBOX360 && !WINDOWS_PHONE +#if WINDOWS /// Waits until the background process finishes or a timeout occurs /// @@ -150,7 +150,7 @@ namespace Nuclex.Support.Tracking { return WaitHandle.WaitOne(timeout, false); } -#endif // !XBOX360 +#endif // WINDOWS /// Waits until the background process finishes or a timeout occurs /// @@ -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 } /// Whether the transaction has ended already