Core - Corrected disposable pattern usage

Core - Further nullable refactoring..
This commit is contained in:
Robert committed 2020-11-17 20:54:49 +01:00
1 parent 27e25f22ed
commit b185b28645
38 files changed
+429 -162

No files matched your search

@@ -97,19 +97,32 @@ namespace Artemis.Core.LayerBrushes
internal abstract void InternalRender(SKCanvas canvas, SKRect path, SKPaint paint);
internal virtual void Dispose(bool disposing)
#region IDisposable
/// <summary>
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
/// </summary>
/// <param name="disposing">
/// <see langword="true" /> to release both managed and unmanaged resources;
/// <see langword="false" /> to release only unmanaged resources.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
DisableLayerBrush();
BaseProperties?.Dispose();
}
}
/// <inheritdoc />
public void Dispose()
{
DisableLayerBrush();
BaseProperties?.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
/// <summary>
@@ -26,7 +26,7 @@ namespace Artemis.Core.LayerBrushes
{
// I imagine a null reference here can be confusing, so lets throw an exception explaining what to do
if (_properties == null)
throw new ArtemisPluginException("Cannot access brush properties until OnPropertiesInitialized has been called");
throw new InvalidOperationException("Cannot access brush properties until OnPropertiesInitialized has been called");
return _properties;
}
internal set => _properties = value;