Files
speckle-sharp-connectors/Converters/Civil3d/Speckle.Converters.Civil3dShared/Helpers/PropertyHandler.cs
T
Mucahit Bilal GOKER a1f392a33b
.NET Build and Publish / build-connectors (push) Has been cancelled
.NET Build and Publish / deploy-installers (push) Has been cancelled
feat: plant 3d connector (#1344)
* wip

* feat: data extraction from db

* Fallback conversions

* Fix line segments

* Fix: do not skip empty values

* Remove claude generated receive boilerplates and civil related extractor

* Fix compile errors and custom assembly resolver

* Guids for bundle

* Nuget

* Use TagValue as object name

* add plant3d to slnx (#1347)

* add plant3d to slnx

* format

* and the local (#1348)

* Resolve comments

* final comments

* lockfiles

* don't swallow image exception

---------

Co-authored-by: oguzhankoral <oguzhankoral@gmail.com>
Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com>
Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com>
2026-04-02 16:20:49 +01:00

43 lines
919 B
C#

namespace Speckle.Converters.Civil3dShared.Helpers;
/// <summary>
/// Used to help with properties on classes that may throw exceptions when accessed
/// </summary>
public sealed class PropertyHandler
{
public bool TryGetValue<T>(Func<T> getValue, out T? value)
{
try
{
value = getValue();
return true;
}
catch (Exception e)
when (e is InvalidOperationException
|| e is ArgumentException
|| e is Autodesk.AutoCAD.Runtime.Exception // eNotApplicable
|| e is Autodesk.Civil.CivilException
)
{
value = default;
return false;
}
}
public bool TryAddToDictionary<T>(Dictionary<string, object?> dict, string key, Func<T> getValue)
{
if (dict.ContainsKey(key))
{
return false;
}
if (TryGetValue<T>(getValue, out var value))
{
dict.Add(key, value);
return true;
}
return false;
}
}