Nullability of TryGet function (#217)
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ public class ArcGISRootObjectBuilder : IRootObjectBuilder<MapMember>
|
||||
// don't use cache for group layers
|
||||
if (
|
||||
mapMember is not GroupLayer
|
||||
&& _sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value)
|
||||
&& _sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference? value)
|
||||
)
|
||||
{
|
||||
converted = value;
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class AutocadRootObjectBuilder : IRootObjectBuilder<AutocadRootObject>
|
||||
{
|
||||
converted = instanceProxy;
|
||||
}
|
||||
else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value))
|
||||
else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference? value))
|
||||
{
|
||||
converted = value;
|
||||
cacheHitCount++;
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class RevitRootObjectBuilder : IRootObjectBuilder<ElementId>
|
||||
try
|
||||
{
|
||||
Base converted;
|
||||
if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value))
|
||||
if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference? value))
|
||||
{
|
||||
converted = value;
|
||||
cacheHitCount++;
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ public class RhinoRootObjectBuilder : IRootObjectBuilder<RhinoObject>
|
||||
{
|
||||
converted = instanceProxies[applicationId];
|
||||
}
|
||||
else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference value))
|
||||
else if (_sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference? value))
|
||||
{
|
||||
converted = value;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Connectors.Utils.Caching;
|
||||
@@ -20,5 +21,5 @@ public interface ISendConversionCache
|
||||
/// <param name="objectIds"></param>
|
||||
public void EvictObjects(IEnumerable<string> objectIds);
|
||||
public void ClearCache();
|
||||
bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference);
|
||||
bool TryGetValue(string projectId, string applicationId, [NotNullWhen(true)] out ObjectReference? objectReference);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Connectors.Utils.Caching;
|
||||
@@ -13,9 +14,13 @@ public class NullSendConversionCache : ISendConversionCache
|
||||
|
||||
public void ClearCache() { }
|
||||
|
||||
public bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference)
|
||||
public bool TryGetValue(
|
||||
string projectId,
|
||||
string applicationId,
|
||||
[NotNullWhen(true)] out ObjectReference? objectReference
|
||||
)
|
||||
{
|
||||
objectReference = new ObjectReference();
|
||||
objectReference = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Connectors.Utils.Caching;
|
||||
@@ -25,6 +26,9 @@ public class SendConversionCache : ISendConversionCache
|
||||
|
||||
public void ClearCache() => Cache.Clear();
|
||||
|
||||
public bool TryGetValue(string projectId, string applicationId, out ObjectReference objectReference) =>
|
||||
Cache.TryGetValue((applicationId, projectId), out objectReference);
|
||||
public bool TryGetValue(
|
||||
string projectId,
|
||||
string applicationId,
|
||||
[NotNullWhen(true)] out ObjectReference? objectReference
|
||||
) => Cache.TryGetValue((applicationId, projectId), out objectReference);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user