Added XNA 4.0 for Windows Phone 7 project; updated Nuclex.Support to compile targeting Windows Phone 7

git-svn-id: file:///srv/devel/repo-conversion/nusu@203 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2010-09-17 15:29:22 +00:00
parent 1aad371ece
commit 374152cd63
15 changed files with 442 additions and 39 deletions

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 });
#else
#elif !WINDOWS_PHONE
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
#if !XBOX360 && !WINDOWS_PHONE
/// <summary>Retrieves the ProcessThread for the calling thread</summary>
/// <returns>The ProcessThread for the calling thread</returns>
internal static ProcessThread GetProcessThread(int threadId) {

View file

@ -294,7 +294,7 @@ namespace Nuclex.Support.Collections {
}
index += this.firstBlockStartIndex;
#if XBOX360
#if XBOX360 || WINDOWS_PHONE
blockIndex = index / this.blockSize;
subIndex = index % this.blockSize;
#else

View file

@ -90,7 +90,7 @@ namespace Nuclex.Support {
/// and cache the result.
/// </remarks>
public static EnumType[] GetValues<EnumType>() {
#if XBOX360
#if XBOX360 || WINDOWS_PHONE
return GetValuesXbox360<EnumType>();
#else
return (EnumType[])Enum.GetValues(typeof(EnumType));

View file

@ -24,7 +24,7 @@ using System.Reflection;
namespace Nuclex.Support.Plugins {
#if XBOX360
#if XBOX360 || WINDOWS_PHONE
/// <summary>Signature for the AssemblyLoad event</summary>
/// <param name="sender">Object that is reporting that an assembly was loaded</param>

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
#if !XBOX360 && !WINDOWS_PHONE
Trace.WriteLine(error);
#endif
}

View file

@ -70,11 +70,11 @@ namespace Nuclex.Support.Plugins {
// 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) {
Trace.WriteLine(
reportError(
"Assembly '" + path + "' or one of its dependencies is missing"
);
}
#endif // !XBOX360
#endif
// Unauthorized acccess - Either the assembly is not trusted because it contains
// code that imposes a security risk on the system or a user rights problem
catch(UnauthorizedAccessException) {
@ -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
#if !XBOX360 && !WINDOWS_PHONE
Trace.WriteLine(error);
#endif
}

View file

@ -94,7 +94,7 @@ namespace Nuclex.Support.Scheduling {
int milliseconds = (int)(ticks / TicksPerMillisecond);
#if XNA_3
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);
#elif XBOX360
#elif XBOX360 || WINDOWS_PHONE
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds));
#else
bool signalled = waitHandle.WaitOne(Math.Min(1000, milliseconds), false);

View file

@ -130,7 +130,7 @@ namespace Nuclex.Support.Scheduling {
this.timerThread.Name = "Nuclex.Support.Scheduling.Scheduler";
#if XNA_3
this.timerThread.Priority = ThreadPriority.Highest;
#elif !XBOX360
#elif !XBOX360 && !WINDOWS_PHONE
this.timerThread.Priority = ThreadPriority.Highest;
#endif
this.timerThread.IsBackground = true;
@ -147,7 +147,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
#if !XBOX360 && !WINDOWS_PHONE
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

@ -22,7 +22,7 @@ using System;
using System.Collections.Generic;
using System.Threading;
#if !XBOX360
#if !NO_SYSTEMEVENTS
using Microsoft.Win32;
#endif
@ -38,9 +38,9 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Initializes a new Windows time source</summary>
public WindowsTimeSource() {
#if XBOX360
#if NO_SYSTEMEVENTS
throw new InvalidOperationException(
"Windows time source is not available on the XBox 360"
"Windows time source is not available without the SystemEvents class"
);
#else
this.onDateTimeAdjustedDelegate = new EventHandler(OnDateTimeAdjusted);
@ -50,8 +50,8 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Immediately releases all resources owned by the instance</summary>
public void Dispose() {
#if !XBOX360
if(this.onDateTimeAdjustedDelegate != null) {
#if !NO_SYSTEMEVENTS
if (this.onDateTimeAdjustedDelegate != null) {
SystemEvents.TimeChanged -= this.onDateTimeAdjustedDelegate;
this.onDateTimeAdjustedDelegate = null;
}
@ -67,7 +67,7 @@ namespace Nuclex.Support.Scheduling {
public override bool WaitOne(AutoResetEvent waitHandle, long ticks) {
#if XNA_3
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond), false);
#elif XBOX360
#elif XBOX360 || WINDOWS_PHONE
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond));
#else
return waitHandle.WaitOne((int)(ticks / TicksPerMillisecond), false);
@ -81,7 +81,7 @@ namespace Nuclex.Support.Scheduling {
get { return Environment.OSVersion.Platform == PlatformID.Win32NT; }
}
#if !XBOX360
#if !NO_SYSTEMEVENTS
/// <summary>Delegate for the timeChanged() callback method</summary>
private EventHandler onDateTimeAdjustedDelegate;

View file

@ -124,14 +124,12 @@ namespace Nuclex.Support {
/// True if the resource was available and is now locked, false if
/// the timeout has been reached.
/// </returns>
#if XNA_3 // XNA 3.0 for XBox 360 had an exitContext parameter
public override bool WaitOne(int millisecondsTimeout, bool exitContext) {
#elif XBOX360 // XNA 4.0 for XBox 360 has no exitContext parameter
#if NO_EXITCONTEXT
public override bool WaitOne(int millisecondsTimeout) {
#else
public override bool WaitOne(int millisecondsTimeout, bool exitContext) {
#endif
for(; ; ) {
for (; ; ) {
// Lock the resource - even if it is full. We will correct out mistake later
// if we overcomitted the resource.
@ -155,9 +153,7 @@ namespace Nuclex.Support {
// Unless we have been preempted by a Release(), we now have to wait for the
// resource to become available.
if(newFree >= 0) {
#if XNA_3 // XNA 3.0 for XBox 360 had an exitContext parameter
if(!this.manualResetEvent.WaitOne(millisecondsTimeout, exitContext)) {
#elif XBOX360 // XNA 4.0 for XBox 360 has no exitContext parameter
#if NO_EXITCONTEXT
if (!this.manualResetEvent.WaitOne(millisecondsTimeout)) {
#else
if(!this.manualResetEvent.WaitOne(millisecondsTimeout, exitContext)) {
@ -177,9 +173,7 @@ namespace Nuclex.Support {
/// the timeout has been reached.
/// </returns>
public override bool WaitOne() {
#if XNA_3 // XNA 3.0 for XBox 360 had an exitContext parameter
return WaitOne(-1, false);
#elif XBOX360 // XNA 4.0 for XBox 360 has no exitContext parameter
#if NO_EXITCONTEXT
return WaitOne(-1);
#else
return WaitOne(-1, false);
@ -187,6 +181,7 @@ namespace Nuclex.Support {
}
#if !(XNA_3 && XBOX360)
/// <summary>
/// Waits for the resource to become available and locks it
/// </summary>
@ -201,7 +196,7 @@ namespace Nuclex.Support {
/// True if the resource was available and is now locked, false if
/// the timeout has been reached.
/// </returns>
#if XBOX360
#if NO_EXITCONTEXT
public override bool WaitOne(TimeSpan timeout) {
#else
public override bool WaitOne(TimeSpan timeout, bool exitContext) {
@ -213,12 +208,13 @@ namespace Nuclex.Support {
);
}
#if XBOX360
#if NO_EXITCONTEXT
return WaitOne((int)totalMilliseconds);
#else
return WaitOne((int)totalMilliseconds, exitContext);
#endif
}
#endif // !(XNA_3 && XBOX360)
/// <summary>

View file

@ -293,7 +293,7 @@ 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 XBOX
#if XBOX360 || WINDOWS_PHONE
int digit = remaining % 10;
int tenth = remaining / 10;
#else
@ -312,7 +312,7 @@ 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 XBOX
#if XBOX360 || WINDOWS_PHONE
long digit = remaining % 10;
long tenth = remaining / 10;
#else

View file

@ -133,7 +133,7 @@ namespace Nuclex.Support.Tracking {
}
}
#if !XBOX360
#if !XBOX360 && !WINDOWS_PHONE
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
/// <param name="timeout">
@ -166,7 +166,7 @@ namespace Nuclex.Support.Tracking {
#if XNA_3
return WaitHandle.WaitOne(timeoutMilliseconds, false);
#elif XBOX360
#elif XBOX360 || WINDOWS_PHONE
return WaitHandle.WaitOne(timeoutMilliseconds);
#else
return WaitHandle.WaitOne(timeoutMilliseconds, false);