using System;

namespace Decal.Adapter.Wrappers;

[CLSCompliant(true)]
public abstract class HostBase : MarshalByRefObject, IDisposable
{
	private HooksWrapper myInternalHooks;

	private DecalWrapper myInternalDecal;

	private RenderServiceWrapper myInternalRender;

	private bool isDisposed;

	protected bool IsDisposed => isDisposed;

	protected DecalWrapper MyDecal
	{
		get
		{
			return myInternalDecal;
		}
		set
		{
			myInternalDecal = value;
		}
	}

	protected RenderServiceWrapper MyRender
	{
		get
		{
			return myInternalRender;
		}
		set
		{
			myInternalRender = value;
		}
	}

	~HostBase()
	{
		Dispose(disposing: false);
	}

	public void Dispose()
	{
		Dispose(disposing: true);
		GC.SuppressFinalize(this);
	}

	protected virtual void Dispose(bool disposing)
	{
		if (!isDisposed && disposing)
		{
			if (myInternalHooks != null)
			{
				myInternalHooks.Dispose();
			}
			if (myInternalDecal != null)
			{
				myInternalDecal.Dispose();
			}
			if (myInternalRender != null)
			{
				myInternalRender.Dispose();
			}
		}
		myInternalHooks = null;
		myInternalDecal = null;
		myInternalRender = null;
		isDisposed = true;
	}
}
