anx.framework/ANX.Framework/Graphics/GraphicsResource.cs

75 lines
1.4 KiB
C#
Raw Normal View History

2011-10-31 05:36:24 +00:00
using System;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
2011-10-31 05:36:24 +00:00
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
2011-10-31 05:36:24 +00:00
namespace ANX.Framework.Graphics
{
public abstract class GraphicsResource : IDisposable
{
public event EventHandler<EventArgs> Disposing;
public GraphicsResource()
{
GraphicsResourceTracker.Instance.RegisterTrackedObject(this);
}
2011-10-31 05:36:24 +00:00
~GraphicsResource()
{
GraphicsResourceTracker.Instance.UnregisterTrackedObject(this);
}
2011-10-31 05:36:24 +00:00
public GraphicsResource(GraphicsDevice device)
{
this.GraphicsDevice = device;
GraphicsResourceTracker.Instance.RegisterTrackedObject(this);
}
2011-10-31 05:36:24 +00:00
public GraphicsDevice GraphicsDevice
{
get;
set;
}
2011-10-31 05:36:24 +00:00
public bool IsDisposed
{
get;
internal set;
}
2011-10-31 05:36:24 +00:00
public string Name
{
get;
set;
}
2011-10-31 05:36:24 +00:00
public object Tag
{
get;
set;
}
2011-10-31 05:36:24 +00:00
public abstract void Dispose();
2011-10-31 05:36:24 +00:00
protected void raise_Disposing(object sender, EventArgs args)
{
if (Disposing != null)
{
Disposing(sender, args);
}
}
2011-10-31 05:36:24 +00:00
protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
}
2011-10-31 05:36:24 +00:00
public override string ToString()
{
return base.ToString();
}
}
2011-10-31 05:36:24 +00:00
}