diff options
Diffstat (limited to 'Xamarin.Forms.Core/WeakReferenceExtensions.cs')
-rw-r--r-- | Xamarin.Forms.Core/WeakReferenceExtensions.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/WeakReferenceExtensions.cs b/Xamarin.Forms.Core/WeakReferenceExtensions.cs new file mode 100644 index 00000000..e4e883a4 --- /dev/null +++ b/Xamarin.Forms.Core/WeakReferenceExtensions.cs @@ -0,0 +1,16 @@ +using System; + +namespace Xamarin.Forms +{ + internal static class WeakReferenceExtensions + { + internal static bool TryGetTarget<T>(this WeakReference self, out T target) where T : class + { + if (self == null) + throw new ArgumentNullException("self"); + + target = (T)self.Target; + return target != null; + } + } +}
\ No newline at end of file |