From 374152cd639b21c64e3dbd1522f62e0a0837d431 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Fri, 17 Sep 2010 15:29:22 +0000 Subject: [PATCH] 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 --- Nuclex.Support (xna-3.1-xbox360).csproj | 4 +- Nuclex.Support (xna-4.0-phone7).csproj | 407 ++++++++++++++++++++++++ Nuclex.Support (xna-4.0-xbox360).csproj | 4 +- Source/AffineThreadPool.cs | 4 +- Source/Collections/Deque.cs | 2 +- Source/EnumHelper.cs | 2 +- Source/Plugins/AssemblyLoadEventArgs.cs | 2 +- Source/Plugins/PluginHost.cs | 2 +- Source/Plugins/PluginRepository.cs | 6 +- Source/Scheduling/GenericTimeSource.cs | 2 +- Source/Scheduling/Scheduler.cs | 4 +- Source/Scheduling/WindowsTimeSource.cs | 14 +- Source/Semaphore.cs | 20 +- Source/StringBuilderHelper.cs | 4 +- Source/Tracking/Transaction.cs | 4 +- 15 files changed, 442 insertions(+), 39 deletions(-) create mode 100644 Nuclex.Support (xna-4.0-phone7).csproj diff --git a/Nuclex.Support (xna-3.1-xbox360).csproj b/Nuclex.Support (xna-3.1-xbox360).csproj index 9a94e18..4e387af 100644 --- a/Nuclex.Support (xna-3.1-xbox360).csproj +++ b/Nuclex.Support (xna-3.1-xbox360).csproj @@ -18,7 +18,7 @@ full false bin\xna-3.1-xbox360\Debug\ - TRACE;DEBUG;XBOX;XBOX360;NO_SERIALIZATION;XNA_3 + TRACE;DEBUG;XBOX;XBOX360;NO_SERIALIZATION;NO_SYSTEMEVENTS;XNA_3 prompt 4 true @@ -30,7 +30,7 @@ pdbonly true bin\xna-3.1-xbox360\Release\ - TRACE;XBOX;XBOX360;NO_SERIALIZATION;XNA_3 + TRACE;XBOX;XBOX360;NO_SERIALIZATION;NO_SYSTEMEVENTS;XNA_3 prompt 4 true diff --git a/Nuclex.Support (xna-4.0-phone7).csproj b/Nuclex.Support (xna-4.0-phone7).csproj new file mode 100644 index 0000000..ed8e7b6 --- /dev/null +++ b/Nuclex.Support (xna-4.0-phone7).csproj @@ -0,0 +1,407 @@ + + + + {7AC614A7-E1FC-4EB9-9229-13B26280FF9B} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + Windows Phone + Library + Properties + Nuclex.Support + Nuclex.Support + v4.0 + Client + v4.0 + Windows Phone + Reach + ab7fffb0-8ac5-44fe-b113-2d14c58c5804 + Library + + + true + full + false + bin\xna-4.0-phone7\Debug\ + TRACE;DEBUG;WINDOWS_PHONE;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT;NO_SYSTEMEVENTS;NO_EXITCONTEXT + prompt + 4 + true + false + false + bin\xna-4.0-phone7\Debug\Nuclex.Support.xml + + + pdbonly + true + bin\xna-4.0-phone7\Release\ + TRACE;WINDOWS_PHONE;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT;NO_SYSTEMEVENTS;NO_EXITCONTEXT + prompt + 4 + true + false + false + bin\xna-4.0-phone7\Release\Nuclex.Support.xml + + + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + 4.0 + False + + + 4.0 + False + + + False + + + + + + AffineThreadPool.cs + + + + Deque.cs + + + Deque.cs + + + Deque.cs + + + Deque.cs + + + Deque.cs + + + + + + ItemEventArgs.cs + + + + ObservableCollection.cs + + + + ObservableDictionary.cs + + + + PairPriorityQueue.cs + + + + Parentable.cs + + + + ParentingCollection.cs + + + + Pool.cs + + + + PriorityItemPair.cs + + + + PriorityQueue.cs + + + + ReadOnlyCollection.cs + + + + ReadOnlyDictionary.cs + + + + ReadOnlyList.cs + + + + ReverseComparer.cs + + + + + EnumHelper.cs + + + + PrototypeFactory.cs + + + GenericTimeSource.cs + + + + + + + Scheduler.cs + + + Scheduler.cs + + + + WindowsTimeSource.cs + + + + Semaphore.cs + + + + AppDomainTypeLister.cs + + + + ExplicitTypeLister.cs + + + + + MultiAssemblyTypeLister.cs + + + + + + + + RepositoryTypeLister.cs + + + ServiceManager.cs + + + + ServiceManager.cs + + + + PartialStream.cs + + + + RingMemoryStream.cs + + + + TransformingReadOnlyCollection.cs + + + TransformingReadOnlyCollection.cs + + + + WeakCollection.cs + + + WeakCollection.cs + + + + FloatHelper.cs + + + + IntegerHelper.cs + + + + LicenseKey.cs + + + CommandLine.cs + + + CommandLine.cs + + + CommandLine.cs + + + + CommandLine.cs + + + + PathHelper.cs + + + + AssemblyLoadEventArgs.cs + + + + Employer.cs + + + FactoryEmployer.cs + + + + InstanceEmployer.cs + + + + + + + NoPluginAttribute.cs + + + + PluginHelper.cs + + + + PluginHost.cs + + + + PluginRepository.cs + + + + AbortedException.cs + + + + + Operation.cs + + + + OperationQueue.cs + + + + ThreadCallbackOperation.cs + + + + ThreadOperation.cs + + + ServiceManager.cs + + + + + Shared.cs + + + + ChainStream.cs + + + + StringBuilderHelper.cs + + + + StringHelper.cs + + + + StringSegment.cs + + + + IdleStateEventArgs.cs + + + + ObservedWeightedTransaction.cs + + + + WeightedTransactionWrapperCollection.cs + + + + + + ProgressReportEventArgs.cs + + + + ProgressTracker.cs + + + + Request.cs + + + StatusReportEventArgs.cs + + + Transaction.cs + + + + TransactionGroup.cs + + + + + + WeightedTransaction.cs + + + + WeakReference.cs + + + + XmlHelper.cs + + + + + + \ No newline at end of file diff --git a/Nuclex.Support (xna-4.0-xbox360).csproj b/Nuclex.Support (xna-4.0-xbox360).csproj index 8c0952c..65601a3 100644 --- a/Nuclex.Support (xna-4.0-xbox360).csproj +++ b/Nuclex.Support (xna-4.0-xbox360).csproj @@ -22,7 +22,7 @@ full false bin\xna-4.0-xbox360\Debug\ - TRACE;DEBUG;XBOX;XBOX360;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT + TRACE;DEBUG;XBOX;XBOX360;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT;NO_SYSTEMEVENTS;NO_EXITCONTEXT prompt 4 true @@ -34,7 +34,7 @@ pdbonly true bin\xna-4.0-xbox360\Release\ - TRACE;XBOX;XBOX360;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT + TRACE;XBOX;XBOX360;NO_CLONING;NO_SERIALIZATION;NO_XMLDOCUMENT;NO_SYSTEMEVENTS;NO_EXITCONTEXT prompt 4 true diff --git a/Source/AffineThreadPool.cs b/Source/AffineThreadPool.cs index 3b0b710..6511ab6 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 }); -#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 /// Retrieves the ProcessThread for the calling thread /// The ProcessThread for the calling thread internal static ProcessThread GetProcessThread(int threadId) { diff --git a/Source/Collections/Deque.cs b/Source/Collections/Deque.cs index 0d3233e..ffe3687 100644 --- a/Source/Collections/Deque.cs +++ b/Source/Collections/Deque.cs @@ -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 diff --git a/Source/EnumHelper.cs b/Source/EnumHelper.cs index bf3d9a0..9c25a8a 100644 --- a/Source/EnumHelper.cs +++ b/Source/EnumHelper.cs @@ -90,7 +90,7 @@ namespace Nuclex.Support { /// and cache the result. /// public static EnumType[] GetValues() { -#if XBOX360 +#if XBOX360 || WINDOWS_PHONE return GetValuesXbox360(); #else return (EnumType[])Enum.GetValues(typeof(EnumType)); diff --git a/Source/Plugins/AssemblyLoadEventArgs.cs b/Source/Plugins/AssemblyLoadEventArgs.cs index b044279..8fd7c69 100644 --- a/Source/Plugins/AssemblyLoadEventArgs.cs +++ b/Source/Plugins/AssemblyLoadEventArgs.cs @@ -24,7 +24,7 @@ using System.Reflection; namespace Nuclex.Support.Plugins { -#if XBOX360 +#if XBOX360 || WINDOWS_PHONE /// Signature for the AssemblyLoad event /// Object that is reporting that an assembly was loaded diff --git a/Source/Plugins/PluginHost.cs b/Source/Plugins/PluginHost.cs index f9b3727..beb0c1e 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 +#if !XBOX360 && !WINDOWS_PHONE Trace.WriteLine(error); #endif } diff --git a/Source/Plugins/PluginRepository.cs b/Source/Plugins/PluginRepository.cs index 077efe8..50a5ec3 100644 --- a/Source/Plugins/PluginRepository.cs +++ b/Source/Plugins/PluginRepository.cs @@ -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 { /// Reports an error to the debugging console /// Error message that will be reported private static void reportError(string error) { -#if !XBOX360 +#if !XBOX360 && !WINDOWS_PHONE Trace.WriteLine(error); #endif } diff --git a/Source/Scheduling/GenericTimeSource.cs b/Source/Scheduling/GenericTimeSource.cs index fbe27a9..da35e8c 100644 --- a/Source/Scheduling/GenericTimeSource.cs +++ b/Source/Scheduling/GenericTimeSource.cs @@ -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); diff --git a/Source/Scheduling/Scheduler.cs b/Source/Scheduling/Scheduler.cs index 57903c3..4d3b6fc 100644 --- a/Source/Scheduling/Scheduler.cs +++ b/Source/Scheduling/Scheduler.cs @@ -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 diff --git a/Source/Scheduling/WindowsTimeSource.cs b/Source/Scheduling/WindowsTimeSource.cs index 96d8c4a..9d66346 100644 --- a/Source/Scheduling/WindowsTimeSource.cs +++ b/Source/Scheduling/WindowsTimeSource.cs @@ -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 { /// Initializes a new Windows time source 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 { /// Immediately releases all resources owned by the instance 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 /// Delegate for the timeChanged() callback method private EventHandler onDateTimeAdjustedDelegate; diff --git a/Source/Semaphore.cs b/Source/Semaphore.cs index 6e3136d..25abf55 100644 --- a/Source/Semaphore.cs +++ b/Source/Semaphore.cs @@ -124,14 +124,12 @@ namespace Nuclex.Support { /// True if the resource was available and is now locked, false if /// the timeout has been reached. /// -#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. /// 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) + /// /// Waits for the resource to become available and locks it /// @@ -201,7 +196,7 @@ namespace Nuclex.Support { /// True if the resource was available and is now locked, false if /// the timeout has been reached. /// -#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) /// diff --git a/Source/StringBuilderHelper.cs b/Source/StringBuilderHelper.cs index 5745f52..351f8dc 100644 --- a/Source/StringBuilderHelper.cs +++ b/Source/StringBuilderHelper.cs @@ -293,7 +293,7 @@ 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 XBOX +#if XBOX360 || WINDOWS_PHONE int digit = remaining % 10; int tenth = remaining / 10; #else @@ -312,7 +312,7 @@ 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 XBOX +#if XBOX360 || WINDOWS_PHONE long digit = remaining % 10; long tenth = remaining / 10; #else diff --git a/Source/Tracking/Transaction.cs b/Source/Tracking/Transaction.cs index 65d291f..2b69109 100644 --- a/Source/Tracking/Transaction.cs +++ b/Source/Tracking/Transaction.cs @@ -133,7 +133,7 @@ namespace Nuclex.Support.Tracking { } } -#if !XBOX360 +#if !XBOX360 && !WINDOWS_PHONE /// Waits until the background process finishes or a timeout occurs /// @@ -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);