// -----------------------------------------------------------------------
//
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// -----------------------------------------------------------------------
namespace Lucene.Net.Support
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
///
/// Represents a weak reference of , which references an object while still allowing
/// that object to be reclaimed by garbage collection.
///
///
///
///
/// C# File:
/// src/Lucene.Net/Support/WeakReferenceOfTTest.cs
///
///
///
/// C# Tests:
/// test/Lucene.Net.Test/Support/WeakReferenceOfTTest.cs
///
///
///
///
/// This was implemented to be the C# equivalent of has a Java WeakReference of T. It should be
/// noted that Silverlight 5
/// already supports WeakReference of T.
///
///
/// The type.
public class WeakReference : WeakReference
where T : class
{
///
/// Initializes a new instance of the class.
///
/// The target.
public WeakReference(T target)
: base(target)
{
}
///
/// Initializes a new instance of the class.
///
/// The target.
/// if set to true [track resurrection].
public WeakReference(T target, bool trackResurrection)
: base(target, trackResurrection)
{
}
///
/// Gets the object (the target) referenced by the current object.
///
///
/// null if the object referenced by the current object has been garbage collected; otherwise, a reference to the object referenced by the current object.
/// The reference to the target object is invalid. This exception can be thrown while setting this property if the value is a null reference or if the object has been finalized during the set operation.
public new T Target
{
get { return (T)base.Target; }
}
}
}