Make TypeNameParser consistently use tabs
[mono-project.git] / netcore / System.Private.CoreLib / src / System / WeakReference.T.cs
bloba108f52769aa46ad86965d9d4ea0d5e29287856b
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System.Runtime.InteropServices;
7 namespace System
9 partial class WeakReference<T>
11 GCHandle handle;
12 bool trackResurrection;
14 T Target {
15 get {
16 GCHandle h = handle;
17 return h.IsAllocated ? (T) h.Target : null;
21 ~WeakReference ()
23 handle.Free ();
26 void Create (T target, bool trackResurrection)
28 if (trackResurrection) {
29 trackResurrection = true;
30 handle = GCHandle.Alloc (target, GCHandleType.WeakTrackResurrection);
31 } else {
32 handle = GCHandle.Alloc (target, GCHandleType.Weak);
36 public void SetTarget (T target)
38 handle.Target = target;
41 bool IsTrackResurrection () => trackResurrection;