Skip to content

Commit

Permalink
fix(archicad): Archicad nullable levels fix (#3032)
Browse files Browse the repository at this point in the history
* archicad level is null

* Fixing braces & throw

Coding standards now ask for {} around single code blocks after If and other areas where single line is acceptable.

Also the if in this case does not need to have an else, as it can just throw if the IF is not entered.

---------

Co-authored-by: József L. Kiss <>
Co-authored-by: Ian Hawley <[email protected]>
  • Loading branch information
jozseflkiss and BovineOx authored Nov 9, 2023
1 parent 13b153e commit e5c7023
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
8 changes: 5 additions & 3 deletions Objects/Objects/BuiltElements/Beam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ public override Level? level
get => archicadLevel;
internal set
{
if (value is not ArchicadLevel l)
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
if (value is ArchicadLevel or null)
{
archicadLevel = value as ArchicadLevel;
}

archicadLevel = l;
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
}
}

Expand Down
8 changes: 5 additions & 3 deletions Objects/Objects/BuiltElements/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ public override Level? level
get => archicadLevel;
internal set
{
if (value is not ArchicadLevel l)
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
if (value is ArchicadLevel or null)
{
archicadLevel = value as ArchicadLevel;
}

archicadLevel = l;
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
}
}

Expand Down
8 changes: 5 additions & 3 deletions Objects/Objects/BuiltElements/Floor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ public override Level? level
get => archicadLevel;
internal set
{
if (value is not ArchicadLevel l)
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
if (value is ArchicadLevel or null)
{
archicadLevel = value as ArchicadLevel;
}

archicadLevel = l;
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
}
}

Expand Down
8 changes: 5 additions & 3 deletions Objects/Objects/BuiltElements/Roof.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ public override Level? level
get => archicadLevel;
internal set
{
if (value is not ArchicadLevel l)
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
if (value is ArchicadLevel or null)
{
archicadLevel = value as ArchicadLevel;
}

archicadLevel = l;
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
}
}

Expand Down
8 changes: 5 additions & 3 deletions Objects/Objects/BuiltElements/Wall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ public override Level? level
get => archicadLevel;
internal set
{
if (value is not ArchicadLevel l)
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
if (value is ArchicadLevel or null)
{
archicadLevel = value as ArchicadLevel;
}

archicadLevel = l;
throw new ArgumentException($"Expected object of type {nameof(ArchicadLevel)}");
}
}

Expand Down

0 comments on commit e5c7023

Please sign in to comment.