using System;
using System.Collections.Generic;

public class GenericReusable<T> : IReusable where T : class, new()
{
	private bool mAvailable = false;
	
	public T Value
	{
		get;
		set;
	}
	
	public static explicit operator T (GenericReusable<T> value)
	{
		return value.Value;
	}
	
	public GenericReusable(T value)
	{
		Value = value;
	}
	
	#region IReusable implementation
	public event EventHandler<EventArgs> Destroyed;
	
	public void Dispose()
	{
		Available = true;
	}

	public void Destroy ()
	{
		Available = false;
		if (Destroyed != null)
		{
			Destroyed(this, EventArgs.Empty);
		}
	}

	public bool Available
	{
		get { return mAvailable; }
		private set { mAvailable = value; }
	}
	#endregion
	
}
