a1f392a33b
* 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>
43 lines
919 B
C#
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;
|
|
}
|
|
}
|