2016-03-22 23:02:25 +03:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms
|
|
|
|
|
{
|
2016-11-15 22:39:48 +03:00
|
|
|
|
static class WeakReferenceExtensions
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
|
|
|
|
internal static bool TryGetTarget<T>(this WeakReference self, out T target) where T : class
|
|
|
|
|
{
|
|
|
|
|
if (self == null)
|
2016-11-15 22:39:48 +03:00
|
|
|
|
throw new ArgumentNullException(nameof(self));
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
target = (T)self.Target;
|
|
|
|
|
return target != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|