diff --git a/Nuclex.Support (net-2.0).csproj b/Nuclex.Support (net-2.0).csproj
index 9ec054e..f6d0af7 100644
--- a/Nuclex.Support (net-2.0).csproj
+++ b/Nuclex.Support (net-2.0).csproj
@@ -351,6 +351,9 @@
WeightedTransaction.cs
+
+ WeakReference.cs
+
WeakReference.cs
diff --git a/Nuclex.Support (net-4.0).csproj b/Nuclex.Support (net-4.0).csproj
index fc8befa..2a14ac7 100644
--- a/Nuclex.Support (net-4.0).csproj
+++ b/Nuclex.Support (net-4.0).csproj
@@ -355,6 +355,9 @@
WeightedTransaction.cs
+
+ WeakReference.cs
+
WeakReference.cs
diff --git a/Nuclex.Support (xna-3.1-xbox360).csproj b/Nuclex.Support (xna-3.1-xbox360).csproj
index df6fd49..0be226f 100644
--- a/Nuclex.Support (xna-3.1-xbox360).csproj
+++ b/Nuclex.Support (xna-3.1-xbox360).csproj
@@ -1,4 +1,4 @@
-
+
{DFFEAB70-51B8-4714-BCA6-79B733BBC520}
{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
@@ -365,6 +365,9 @@
WeightedTransaction.cs
+
+ WeakReference.cs
+
WeakReference.cs
diff --git a/Nuclex.Support (xna-4.0-phone7).csproj b/Nuclex.Support (xna-4.0-phone7).csproj
index d2c20cf..30116cd 100644
--- a/Nuclex.Support (xna-4.0-phone7).csproj
+++ b/Nuclex.Support (xna-4.0-phone7).csproj
@@ -386,6 +386,9 @@
WeightedTransaction.cs
+
+ WeakReference.cs
+
WeakReference.cs
diff --git a/Nuclex.Support (xna-4.0-xbox360).csproj b/Nuclex.Support (xna-4.0-xbox360).csproj
index 526828d..fb3e417 100644
--- a/Nuclex.Support (xna-4.0-xbox360).csproj
+++ b/Nuclex.Support (xna-4.0-xbox360).csproj
@@ -397,6 +397,9 @@
WeightedTransaction.cs
+
+ WeakReference.cs
+
WeakReference.cs
diff --git a/Source/StringBuilderHelper.cs b/Source/StringBuilderHelper.cs
index 351f8dc..fe0a17f 100644
--- a/Source/StringBuilderHelper.cs
+++ b/Source/StringBuilderHelper.cs
@@ -26,7 +26,7 @@ using System.Text;
namespace Nuclex.Support {
/// Contains helper methods for the string builder class
- public class StringBuilderHelper {
+ public static class StringBuilderHelper {
/// Predefined unicode characters for the numbers 0 to 9
private static readonly char[] numbers = new char[] {
diff --git a/Source/WeakReference.Phone7.cs b/Source/WeakReference.Phone7.cs
new file mode 100644
index 0000000..2f00446
--- /dev/null
+++ b/Source/WeakReference.Phone7.cs
@@ -0,0 +1,106 @@
+#region CPL License
+/*
+Nuclex Framework
+Copyright (C) 2002-2010 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;
+
+namespace Nuclex.Support {
+
+#if WINDOWS_PHONE
+
+ ///
+ /// Type-safe weak reference, referencing an object while still allowing
+ /// that object to be garbage collected.
+ ///
+ public class WeakReference
+ where ReferencedType : class {
+
+ ///
+ /// Initializes a new instance of the WeakReference class, referencing
+ /// the specified object.
+ ///
+ /// The object to track or null.
+ public WeakReference(ReferencedType target) {
+ this.weakReference = new WeakReference(target);
+ }
+
+ ///
+ /// Initializes a new instance of the WeakReference class, referencing
+ /// the specified object optionally using resurrection tracking.
+ ///
+ /// An object to track.
+ ///
+ /// Indicates when to stop tracking the object. If true, the object is tracked
+ /// after finalization; if false, the object is only tracked until finalization.
+ ///
+ public WeakReference(ReferencedType target, bool trackResurrection) {
+ this.weakReference = new WeakReference(target, trackResurrection);
+ }
+
+ ///
+ /// Implicitly converts a typed WeakReference into a non-typesafe WeakReference
+ ///
+ /// The types WeakReference that will be converted
+ /// The non-typesafe WeakReference
+ public static implicit operator WeakReference(WeakReference self) {
+ return self.weakReference;
+ }
+
+ ///
+ /// Gets or sets the object (the target) referenced by the current WeakReference
+ /// object.
+ ///
+ ///
+ /// Is null if the object referenced by the current System.WeakReference object
+ /// has been garbage collected; otherwise, a reference to the object referenced
+ /// by the current System.WeakReference object.
+ ///
+ ///
+ /// The reference to the target object is invalid. This can occur if the current
+ /// System.WeakReference object has been finalized
+ ///
+ public ReferencedType Target {
+ get { return this.weakReference.Target as ReferencedType; }
+ set { this.weakReference.Target = value; }
+ }
+
+ ///
+ /// whether the object referenced by the WeakReference has been garbage collected
+ ///
+ public virtual bool IsAlive {
+ get { return this.weakReference.IsAlive; }
+ }
+
+ ///
+ /// Whether the object referenced by the WeakReference is tracked after it is finalized
+ ///
+ public virtual bool TrackResurrection {
+ get { return this.weakReference.TrackResurrection; }
+ }
+
+ /// The non-typesafe WeakReference being wrapped
+ private WeakReference weakReference;
+
+ }
+
+#endif // WINDOWS_PHONE
+
+} // namespace Nuclex.Support
+
diff --git a/Source/WeakReference.cs b/Source/WeakReference.cs
index a815313..9377449 100644
--- a/Source/WeakReference.cs
+++ b/Source/WeakReference.cs
@@ -24,6 +24,8 @@ using System.Runtime.Serialization;
namespace Nuclex.Support {
+#if !WINDOWS_PHONE
+
///
/// Type-safe weak reference, referencing an object while still allowing
/// that object to be garbage collected.
@@ -96,4 +98,6 @@ namespace Nuclex.Support {
}
+#endif // !WINDOWS_PHONE
+
} // namespace Nuclex.Support