Made Nuclex.Support compileable on the XBox 360; added new XNA 3.0 project to compile Nuclex.Support on the XBox 360; added my own AssemblyLoadEventArgs implementation since the XBox 360 XNA framework doesn't provide it; other minor fixes so Nuclex.Support can cope with the XBox 360 XNA framework
git-svn-id: file:///srv/devel/repo-conversion/nusu@113 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
8f6616f79a
commit
0a483b4d44
19 changed files with 473 additions and 28 deletions
|
@ -18,14 +18,14 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
|
|
@ -31,10 +31,14 @@ namespace Nuclex.Support.Collections {
|
|||
/// <typeparam name="ValueType">Type of the values used in the Dictionary</typeparam>
|
||||
[Serializable]
|
||||
public class ReadOnlyDictionary<KeyType, ValueType> :
|
||||
IDictionary<KeyType, ValueType>,
|
||||
IDictionary,
|
||||
#if !COMPACTFRAMEWORK
|
||||
ISerializable,
|
||||
IDeserializationCallback {
|
||||
IDeserializationCallback,
|
||||
#endif
|
||||
IDictionary<KeyType, ValueType>,
|
||||
IDictionary {
|
||||
|
||||
#if !COMPACTFRAMEWORK
|
||||
|
||||
#region class SerializedDictionary
|
||||
|
||||
|
@ -65,13 +69,6 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
#endregion // class SerializeDictionary
|
||||
|
||||
/// <summary>Initializes a new read-only Dictionary wrapper</summary>
|
||||
/// <param name="dictionary">Dictionary that will be wrapped</param>
|
||||
public ReadOnlyDictionary(IDictionary<KeyType, ValueType> dictionary) {
|
||||
this.typedDictionary = dictionary;
|
||||
this.objectDictionary = (this.typedDictionary as IDictionary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the System.WeakReference class, using deserialized
|
||||
/// data from the specified serialization and stream objects.
|
||||
|
@ -90,6 +87,16 @@ namespace Nuclex.Support.Collections {
|
|||
protected ReadOnlyDictionary(SerializationInfo info, StreamingContext context) :
|
||||
this(new SerializedDictionary(info, context)) { }
|
||||
|
||||
#endif // !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>Initializes a new read-only Dictionary wrapper</summary>
|
||||
/// <param name="dictionary">Dictionary that will be wrapped</param>
|
||||
public ReadOnlyDictionary(IDictionary<KeyType, ValueType> dictionary) {
|
||||
this.typedDictionary = dictionary;
|
||||
this.objectDictionary = (this.typedDictionary as IDictionary);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Whether the directory is write-protected</summary>
|
||||
public bool IsReadOnly {
|
||||
get { return true; }
|
||||
|
@ -360,6 +367,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
#endregion
|
||||
|
||||
#if !COMPACTFRAMEWORK
|
||||
#region ISerializable implementation
|
||||
|
||||
/// <summary>Serializes the Dictionary</summary>
|
||||
|
@ -380,6 +388,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
#endregion
|
||||
#endif //!COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
||||
private IDictionary<KeyType, ValueType> typedDictionary;
|
||||
|
|
|
@ -18,6 +18,8 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -99,3 +101,5 @@ namespace Nuclex.Support {
|
|||
}
|
||||
|
||||
} // namespace Nuclex.Support
|
||||
|
||||
#endif // UNITTEST
|
|
@ -182,10 +182,10 @@ namespace Nuclex.Support.Licensing {
|
|||
);
|
||||
|
||||
// Now build a nice, readable string from the decoded characters
|
||||
resultBuilder.Insert(5, '-');
|
||||
resultBuilder.Insert(11, '-');
|
||||
resultBuilder.Insert(17, '-');
|
||||
resultBuilder.Insert(23, '-');
|
||||
resultBuilder.Insert(5, keyDelimiter, 0, 1);
|
||||
resultBuilder.Insert(11, keyDelimiter, 0, 1);
|
||||
resultBuilder.Insert(17, keyDelimiter, 0, 1);
|
||||
resultBuilder.Insert(23, keyDelimiter, 0, 1);
|
||||
return resultBuilder.ToString();
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,13 @@ namespace Nuclex.Support.Licensing {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Character used to delimit each 5 digit group in a license key</summary>
|
||||
/// <remarks>
|
||||
/// Required to be a char array because the .NET Compact Framework only provides
|
||||
/// an overload for char[] in the StringBuilder.Insert() method.
|
||||
/// </remarks>
|
||||
private static char[] keyDelimiter = new char[] { '-' };
|
||||
|
||||
/// <summary>Table with the individual characters in a key</summary>
|
||||
private static readonly string codeTable =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
|
52
Source/Plugins/AssemblyLoadEventArgs.Test.cs
Normal file
52
Source/Plugins/AssemblyLoadEventArgs.Test.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
#region CPL License
|
||||
/*
|
||||
Nuclex Framework
|
||||
Copyright (C) 2002-2009 Nuclex Development Labs
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
published by the IBM Corporation; either version 1.0 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
IBM Common Public License for more details.
|
||||
|
||||
You should have received a copy of the IBM Common Public
|
||||
License along with this library
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.SyntaxHelpers;
|
||||
|
||||
namespace Nuclex.Support.Plugins {
|
||||
|
||||
/// <summary>Unit Test for the assembly load event argument container</summary>
|
||||
[TestFixture]
|
||||
public class AssemblyLoadEventArgsTest {
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the argument container correctly stores an assembly reference
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestEmployerDefaultConstructorDetection() {
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
AssemblyLoadEventArgs testArguments = new AssemblyLoadEventArgs(assembly);
|
||||
|
||||
Assert.AreSame(assembly, testArguments.LoadedAssembly);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.Plugins
|
||||
|
||||
#endif // UNITTEST
|
53
Source/Plugins/AssemblyLoadEventArgs.cs
Normal file
53
Source/Plugins/AssemblyLoadEventArgs.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
#region CPL License
|
||||
/*
|
||||
Nuclex Framework
|
||||
Copyright (C) 2002-2009 Nuclex Development Labs
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
published by the IBM Corporation; either version 1.0 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
IBM Common Public License for more details.
|
||||
|
||||
You should have received a copy of the IBM Common Public
|
||||
License along with this library
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Nuclex.Support.Plugins {
|
||||
|
||||
/// <summary>Signature for the AssemblyLoad event</summary>
|
||||
/// <param name="sender">Object that is reporting that an assembly was loaded</param>
|
||||
/// <param name="arguments">Contains the loaded assembly</param>
|
||||
public delegate void AssemblyLoadEventHandler(
|
||||
object sender, AssemblyLoadEventArgs arguments
|
||||
);
|
||||
|
||||
/// <summary>Argument container for the AssemblyLoad event arguments</summary>
|
||||
public class AssemblyLoadEventArgs : EventArgs {
|
||||
|
||||
/// <summary>Initializes a new event argument container</summary>
|
||||
/// <param name="loadedAssembly">Assembly that has been loaded</param>
|
||||
public AssemblyLoadEventArgs(Assembly loadedAssembly) {
|
||||
this.loadedAssembly = loadedAssembly;
|
||||
}
|
||||
|
||||
/// <summary>Assembly that was loaded by the sender of the event</summary>
|
||||
public Assembly LoadedAssembly {
|
||||
get { return this.loadedAssembly; }
|
||||
}
|
||||
|
||||
/// <summary>Loaded assembly that will be provided to the event receivers</summary>
|
||||
private Assembly loadedAssembly;
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.Plugins
|
|
@ -18,11 +18,11 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.SyntaxHelpers;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Nuclex.Support.Plugins {
|
|||
/// <param name="path">Path the assembly will be loaded from</param>
|
||||
/// <returns>The loaded assembly</returns>
|
||||
protected virtual Assembly LoadAssemblyFromFile(string path) {
|
||||
return Assembly.LoadFile(path);
|
||||
return Assembly.LoadFrom(path);
|
||||
}
|
||||
|
||||
/// <summary>Tries to loads an assembly from a file</summary>
|
||||
|
@ -66,6 +66,7 @@ namespace Nuclex.Support.Plugins {
|
|||
loadedAssembly = LoadAssemblyFromFile(path);
|
||||
return true;
|
||||
}
|
||||
#if !COMPACTFRAMEWORK
|
||||
// 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) {
|
||||
|
@ -73,6 +74,7 @@ namespace Nuclex.Support.Plugins {
|
|||
"Assembly '" + path + "' or one of its dependencies is missing"
|
||||
);
|
||||
}
|
||||
#endif // !COMPACTFRAMEWORK
|
||||
// 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) {
|
||||
|
|
|
@ -18,12 +18,13 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NMock2;
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// <param name="inner">Preceding exception that has caused this exception</param>
|
||||
public AbortedException(string message, Exception inner) : base(message, inner) { }
|
||||
|
||||
#if !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>Initializes the exception from its serialized state</summary>
|
||||
/// <param name="info">Contains the serialized fields of the exception</param>
|
||||
/// <param name="context">Additional environmental informations</param>
|
||||
|
@ -52,6 +54,8 @@ namespace Nuclex.Support.Scheduling {
|
|||
)
|
||||
: base(info, context) { }
|
||||
|
||||
#endif // !COMPACTFRAMEWORK
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.Scheduling
|
||||
|
|
|
@ -18,12 +18,13 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NMock2;
|
||||
|
|
|
@ -18,14 +18,14 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Threading;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NMock2;
|
||||
|
||||
|
|
|
@ -18,12 +18,13 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NMock2;
|
||||
|
|
|
@ -57,9 +57,9 @@ namespace Nuclex.Support.Scheduling {
|
|||
"Operations cannot be re-run"
|
||||
);
|
||||
if(useThreadPool) {
|
||||
ThreadPool.QueueUserWorkItem(callMethod);
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(callMethod));
|
||||
} else {
|
||||
Thread thread = new Thread(callMethod);
|
||||
Thread thread = new Thread(new ThreadStart(callMethod));
|
||||
thread.Name = "Nuclex.Support.Scheduling.ThreadOperation";
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
|
@ -72,6 +72,11 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// <summary>Invokes the delegate passed as an argument</summary>
|
||||
/// <param name="state">Not used</param>
|
||||
private void callMethod(object state) {
|
||||
callMethod();
|
||||
}
|
||||
|
||||
/// <summary>Invokes the delegate passed as an argument</summary>
|
||||
private void callMethod() {
|
||||
try {
|
||||
Execute();
|
||||
Debug.Assert(
|
||||
|
|
|
@ -127,6 +127,8 @@ namespace Nuclex.Support.Tracking {
|
|||
WaitHandle.WaitOne();
|
||||
}
|
||||
|
||||
#if !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
||||
/// <param name="timeout">
|
||||
/// Time span after which to stop waiting and return immediately
|
||||
|
@ -138,6 +140,8 @@ namespace Nuclex.Support.Tracking {
|
|||
return WaitHandle.WaitOne(timeout, false);
|
||||
}
|
||||
|
||||
#endif // !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>Waits until the background process finishes or a timeout occurs</summary>
|
||||
/// <param name="timeoutMilliseconds">
|
||||
/// Number of milliseconds after which to stop waiting and return immediately
|
||||
|
|
|
@ -18,12 +18,12 @@ License along with this library
|
|||
*/
|
||||
#endregion
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
#if UNITTEST
|
||||
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.SyntaxHelpers;
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ namespace Nuclex.Support {
|
|||
public WeakReference(ReferencedType target, bool trackResurrection)
|
||||
: base(target, trackResurrection) { }
|
||||
|
||||
#if !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the WeakReference class, using deserialized
|
||||
/// data from the specified serialization and stream objects.
|
||||
|
@ -70,6 +72,8 @@ namespace Nuclex.Support {
|
|||
protected WeakReference(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
|
||||
#endif // !COMPACTFRAMEWORK
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the object (the target) referenced by the current WeakReference
|
||||
/// object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue