Clean up dispose pattern, remove sentence fragment

This commit is contained in:
Steve Hawley 2022-01-21 10:03:49 -05:00
Родитель ef5475c172
Коммит 25d3e11305
7 изменённых файлов: 33 добавлений и 42 удалений

Просмотреть файл

@ -124,7 +124,7 @@ The Swift code uses five files to organize the behavior of the single class `Vie
I occasionally refactored the Swift code where I thought it helped legibility or reduced repetition. Usually this was in the form of extracting a function.
One area where there is considerably variance from the Swift code is in the "Utility_Extensions" folder. Xamarin.iOS uses OpenTK vector and matrix classes for manipulating 3D objects and transforms. The OpenTK classes have different APIs and
One area where there is considerably variance from the Swift code is in the "Utility_Extensions" folder. Xamarin.iOS uses OpenTK vector and matrix classes for manipulating 3D objects and transforms.
A matter of internal debate was the clearest form for porting Swift `guard` statements that assign a local variable if the passed-in variable is not `null`. The options are:

Просмотреть файл

@ -801,26 +801,16 @@ internal class BoundingBox : SCNNode
// Dispose pattern for debugging purposes
bool disposed = false;
internal bool IsDisposed
{
get
{
return disposed;
}
}
internal bool IsDisposed => disposed;
override protected void Dispose (bool disposing)
{
if (!disposed)
{
disposed = true;
if (disposing)
{
base.Dispose ();
}
NSNotificationCenter.DefaultCenter.RemoveObserver (notificationObserverHandle);
}
base.Dispose (disposing);
}
internal new void Dispose ()

Просмотреть файл

@ -515,13 +515,9 @@ internal class ObjectOrigin : SCNNode
{
disposed = true;
if (disposing)
{
base.Dispose ();
}
NSNotificationCenter.DefaultCenter.RemoveObserver (notificationObserverHandles [0]);
NSNotificationCenter.DefaultCenter.RemoveObserver (notificationObserverHandles [1]);
}
base.Dispose (disposing);
}
}

Просмотреть файл

@ -341,16 +341,12 @@ internal class ScannedObject : SCNNode
if (!disposed)
{
disposed = true;
if (disposing)
{
base.Dispose ();
}
NSNotificationCenter.DefaultCenter.RemoveObserver (notificationObserverHandle);
Origin?.Dispose ();
BoundingBox?.Dispose ();
GhostBoundingBox?.Dispose ();
}
base.Dispose (disposing);
}
#endregion

Просмотреть файл

@ -142,15 +142,11 @@ internal class ScannedPointCloud : SCNNode
if (!disposed)
{
disposed = true;
if (disposing)
{
base.Dispose ();
}
foreach (var notificationObserverHandle in notificationObservationHandles)
{
NSNotificationCenter.DefaultCenter.RemoveObserver (notificationObserverHandle);
}
}
base.Dispose (disposing);
}
}

Просмотреть файл

@ -152,6 +152,7 @@ Do you want to go back and adjust the bounding box of the scanned object?""";
sceneView.Scene.RootNode.AddChildNode (pointCloud);
}
bool disposed;
internal new void Dispose ()
{
Dispose (true);
@ -160,6 +161,9 @@ Do you want to go back and adjust the bounding box of the scanned object?""";
protected override void Dispose (bool disposing)
{
if (!disposed)
{
disposed = true;
if (disposing)
{
scannedObject?.RemoveFromParentNode ();
@ -169,6 +173,8 @@ Do you want to go back and adjust the bounding box of the scanned object?""";
pointCloud?.Dispose ();
}
}
base.Dispose (disposing);
}
void ApplicationStateChanged (NSNotification notification)
{

Просмотреть файл

@ -115,6 +115,8 @@ internal class TestRun : NSObject, IDisposable
noDetectionTimer = null;
}
bool disposed;
internal new void Dispose ()
{
Dispose (true);
@ -123,6 +125,9 @@ internal class TestRun : NSObject, IDisposable
protected override void Dispose (bool disposing)
{
if (!disposed)
{
disposed = true;
if (disposing)
{
DetectedObject?.RemoveFromParentNode ();
@ -136,5 +141,7 @@ internal class TestRun : NSObject, IDisposable
sceneView.Session.Run (configuration, ARSessionRunOptions.ResetTracking);
}
}
base.Dispose (disposing);
}
}
}