Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update forge units package #14480

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Libraries/DynamoUnits/Quantity.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using Autodesk.DesignScript.Runtime;
#if NET6_0_OR_GREATER
using ForgeUnitsCLR = Autodesk.ForgeUnits;
#endif
using ForgeUnits = Autodesk.ForgeUnits;

namespace DynamoUnits
{
Expand All @@ -12,9 +10,9 @@ namespace DynamoUnits
/// </summary>
public class Quantity
{
internal readonly ForgeUnitsCLR.Quantity forgeQuantity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this namespace change? If so why is this package not version 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

answered in the general chat

internal readonly ForgeUnits.Quantity forgeQuantity;

internal Quantity(ForgeUnitsCLR.Quantity quantity)
internal Quantity(ForgeUnits.Quantity quantity)
{
this.forgeQuantity = quantity ?? throw new ArgumentNullException();
}
Expand Down
11 changes: 4 additions & 7 deletions src/Libraries/DynamoUnits/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Autodesk.DesignScript.Runtime;

#if NET6_0_OR_GREATER
using ForgeUnitsCLR = Autodesk.ForgeUnits;
#endif
using ForgeUnits = Autodesk.ForgeUnits;

namespace DynamoUnits
{
Expand All @@ -14,10 +11,10 @@ namespace DynamoUnits
/// </summary>
public class Symbol
{
internal readonly ForgeUnitsCLR.Symbol forgeSymbol;
internal readonly ForgeUnitsCLR.PrefixOrSuffix forgePrefixOrSuffix;
internal readonly ForgeUnits.Symbol forgeSymbol;
internal readonly ForgeUnits.PrefixOrSuffix forgePrefixOrSuffix;

internal Symbol(ForgeUnitsCLR.Symbol symbol)
internal Symbol(ForgeUnits.Symbol symbol)
{
this.forgeSymbol = symbol ?? throw new ArgumentNullException();
this.forgePrefixOrSuffix = symbol.getPrefixOrSuffix();
Expand Down
10 changes: 4 additions & 6 deletions src/Libraries/DynamoUnits/Unit.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using Autodesk.DesignScript.Runtime;
#if NET6_0_OR_GREATER
using ForgeUnitsCLR = Autodesk.ForgeUnits;
#endif
using ForgeUnits = Autodesk.ForgeUnits;

namespace DynamoUnits
{
Expand All @@ -12,9 +10,9 @@ namespace DynamoUnits
/// </summary>
public class Unit
{
internal readonly ForgeUnitsCLR.Unit forgeUnit;
internal readonly ForgeUnits.Unit forgeUnit;

internal Unit(ForgeUnitsCLR.Unit unit)
internal Unit(ForgeUnits.Unit unit)
{
this.forgeUnit = unit ?? throw new ArgumentNullException();
}
Expand All @@ -39,7 +37,7 @@ public IEnumerable<Unit> ConvertibleUnits
{
get
{
Dictionary<string, ForgeUnitsCLR.Unit> units = Utilities.ForgeUnitsEngine.getConvertibleUnits(TypeId);
Dictionary<string, ForgeUnits.Unit> units = Utilities.ForgeUnitsEngine.getConvertibleUnits(TypeId);
return Utilities.ConvertForgeUnitDictionaryToCollection(units);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/DynamoUnits/UnitsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ForgeUnits.NET" Version="4.0.3" GeneratePathProperty="true">
<PackageReference Include="ForgeUnits.NET" Version="4.1.1" GeneratePathProperty="true">
<ExcludeAssets>build</ExcludeAssets>
</PackageReference>
<PackageReference Include="ForgeUnits.Schemas" Version="1.0.0" GeneratePathProperty="true" />
<PackageReference Include="ForgeUnits.Schemas" Version="1.0.1" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>
<Content Include="DynamoUnits_DynamoCustomization.xml" />
Expand Down
30 changes: 13 additions & 17 deletions src/Libraries/DynamoUnits/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
using System.Reflection;
using System.IO;
using System.Configuration;

#if NET6_0_OR_GREATER
using ForgeUnitsCLR = Autodesk.ForgeUnits;
using SchemasCLR = Autodesk.ForgeUnits;
#endif
using ForgeUnits = Autodesk.ForgeUnits;

namespace DynamoUnits
{
Expand All @@ -17,7 +13,7 @@ namespace DynamoUnits
/// </summary>
public static class Utilities
{
private static ForgeUnitsCLR.UnitsEngine unitsEngine;
private static ForgeUnits.UnitsEngine unitsEngine;

/// <summary>
/// Path to the directory used load the schema definitions.
Expand Down Expand Up @@ -53,8 +49,8 @@ internal static void Initialize()

try
{
unitsEngine = new ForgeUnitsCLR.UnitsEngine();
SchemasCLR.SchemaUtility.addDefinitionsFromFolder(SchemaDirectory, unitsEngine);
unitsEngine = new ForgeUnits.UnitsEngine();
ForgeUnits.SchemaUtility.addDefinitionsFromFolder(SchemaDirectory, unitsEngine);
unitsEngine.resolveSchemas();
}
catch
Expand All @@ -72,8 +68,8 @@ internal static void SetTestEngine(string testSchemaDir)
{
try
{
unitsEngine = new ForgeUnitsCLR.UnitsEngine();
SchemasCLR.SchemaUtility.addDefinitionsFromFolder(testSchemaDir, unitsEngine);
unitsEngine = new ForgeUnits.UnitsEngine();
ForgeUnits.SchemaUtility.addDefinitionsFromFolder(testSchemaDir, unitsEngine);
unitsEngine.resolveSchemas();
}
catch
Expand Down Expand Up @@ -146,7 +142,7 @@ public static double ParseExpression(string expression)
/// <summary>
/// Engine which loads schemas and is responsible for all ForgeUnit operations.
/// </summary>
internal static ForgeUnitsCLR.UnitsEngine ForgeUnitsEngine
internal static ForgeUnits.UnitsEngine ForgeUnitsEngine
{
get
{
Expand Down Expand Up @@ -205,7 +201,7 @@ public static IEnumerable<Symbol> GetAllSymbols()
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Quantities as values</param>
/// <returns></returns>
internal static IEnumerable<Quantity> CovertForgeQuantityDictionaryToCollection(
Dictionary<string, ForgeUnitsCLR.Quantity> forgeDictionary)
Dictionary<string, ForgeUnits.Quantity> forgeDictionary)
{
var dynQuantities = new List<Quantity>();

Expand All @@ -229,7 +225,7 @@ internal static IEnumerable<Quantity> CovertForgeQuantityDictionaryToCollection(
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Symbols as values</param>
/// <returns></returns>
internal static IEnumerable<Symbol> ConvertForgeSymbolDictionaryToCollection(
Dictionary<string, ForgeUnitsCLR.Symbol> forgeDictionary)
Dictionary<string, ForgeUnits.Symbol> forgeDictionary)
{
var dynSymbols = new List<Symbol>();

Expand All @@ -253,7 +249,7 @@ internal static IEnumerable<Symbol> ConvertForgeSymbolDictionaryToCollection(
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Units as values</param>
/// <returns></returns>
internal static IEnumerable<Unit> ConvertForgeUnitDictionaryToCollection(
Dictionary<string, ForgeUnitsCLR.Unit> forgeDictionary)
Dictionary<string, ForgeUnits.Unit> forgeDictionary)
{
var dynUnits = new List<Unit>();

Expand Down Expand Up @@ -285,7 +281,7 @@ internal static Dictionary<string, Version> GetAllRegisteredQuantityVersions()
/// </summary>
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Quantities as values</param>
/// <returns>A dictionary keyed by a version-less typeID and the latest registered version as value</returns>
internal static Dictionary<string, Version> GetAllRegisteredQuantityVersions(Dictionary<string, ForgeUnitsCLR.Quantity> forgeDictionary)
internal static Dictionary<string, Version> GetAllRegisteredQuantityVersions(Dictionary<string, ForgeUnits.Quantity> forgeDictionary)
{
var versionDictionary = new Dictionary<string, Version>();

Expand Down Expand Up @@ -322,7 +318,7 @@ internal static Dictionary<string, Version> GetAllLastestRegisteredSymbolVersion
/// </summary>
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Symbols as values</param>
/// <returns>A dictionary keyed by a version-less typeID and the latest registered version as value</returns>
internal static Dictionary<string, Version> GetAllLastestRegisteredSymbolVersions(Dictionary<string, ForgeUnitsCLR.Symbol> forgeDictionary)
internal static Dictionary<string, Version> GetAllLastestRegisteredSymbolVersions(Dictionary<string, ForgeUnits.Symbol> forgeDictionary)
{
var versionDictionary = new Dictionary<string, Version>();

Expand Down Expand Up @@ -359,7 +355,7 @@ internal static Dictionary<string, Version> GetAllLatestRegisteredUnitVersions()
/// </summary>
/// <param name="forgeDictionary">A dictionary keyed by a forge typeID and Forge SDK Units as values</param>
/// <returns>A dictionary keyed by a version-less typeID and the latest registered version as value</returns>
internal static Dictionary<string, Version> GetAllLatestRegisteredUnitVersions(Dictionary<string, ForgeUnitsCLR.Unit> forgeDictionary)
internal static Dictionary<string, Version> GetAllLatestRegisteredUnitVersions(Dictionary<string, ForgeUnits.Unit> forgeDictionary)
{
var versionDictionary = new Dictionary<string, Version>();

Expand Down
Loading