Skip to content

Commit

Permalink
Merge pull request #271 from arup-group/GSAGH-177-Use-new-AppDomain-t…
Browse files Browse the repository at this point in the history
…o-avoid-dll-hell

GSAGH-177-Use-new-AppDomain-to-avoid-dll-hell
  • Loading branch information
tlmnrnhrdt authored Jan 11, 2023
2 parents 251ef9c + fac3ed9 commit e742801
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 51 deletions.
32 changes: 19 additions & 13 deletions GsaGH/Components/1_Properties/CreateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

namespace GsaGH.Components
{
/// <summary>
/// Component to create AdSec profile
/// </summary>
public class CreateProfile : GH_OasysDropDownComponent
/// <summary>
/// Component to create AdSec profile
/// </summary>
public class CreateProfile : GH_OasysDropDownComponent
{
#region Name and Ribbon Layout
// This region handles how the component in displayed on the ribbon including name, exposure level and icon
Expand All @@ -32,6 +32,7 @@ public class CreateProfile : GH_OasysDropDownComponent
public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance;
protected override System.Drawing.Bitmap Icon => Properties.Resources.CreateProfile;


public CreateProfile()
: base("Create Profile", "Profile", "Create Profile text-string for a GSA Section",
CategoryName.Name(),
Expand Down Expand Up @@ -881,19 +882,19 @@ private void Mode2Clicked()

// for catalogue selection
// Catalogues
private readonly Tuple<List<string>, List<int>> _cataloguedata = SqlReader.GetCataloguesDataFromSQLite(Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
private readonly Tuple<List<string>, List<int>> _cataloguedata = SqlReader.Instance.GetCataloguesDataFromSQLite(Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
private List<int> _catalogueNumbers = new List<int>(); // internal db catalogue numbers
private List<string> _catalogueNames = new List<string>(); // list of displayed catalogues
bool _inclSS;

// Types
private Tuple<List<string>, List<int>> _typedata = SqlReader.GetTypesDataFromSQLite(-1, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), false);
private Tuple<List<string>, List<int>> _typedata = SqlReader.Instance.GetTypesDataFromSQLite(-1, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), false);
private List<int> _typeNumbers = new List<int>(); // internal db type numbers
private List<string> _typeNames = new List<string>(); // list of displayed types

// Sections
// list of displayed sections
private List<string> _sectionList = SqlReader.GetSectionsDataFromSQLite(new List<int> { -1 }, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), false);
private List<string> _sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(new List<int> { -1 }, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), false);
private List<string> _filteredlist = new List<string>();
int _catalogueIndex = -1; //-1 is all
int _typeIndex = -1;
Expand Down Expand Up @@ -960,12 +961,12 @@ public override void SetSelected(int i, int j)
// set types to all
_typeIndex = -1;
// update typelist with all catalogues
_typedata = SqlReader.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typedata = this.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typeNames = _typedata.Item1;
_typeNumbers = _typedata.Item2;

// update section list to all types
_sectionList = SqlReader.GetSectionsDataFromSQLite(_typeNumbers, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(_typeNumbers, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);

// filter by search pattern
_filteredlist = new List<string>();
Expand Down Expand Up @@ -1021,14 +1022,14 @@ public override void SetSelected(int i, int j)
SelectedItems[1] = _catalogueNames[j];

// update typelist with selected input catalogue
_typedata = SqlReader.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typedata = SqlReader.Instance.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typeNames = _typedata.Item1;
_typeNumbers = _typedata.Item2;

// update section list from new types (all new types in catalogue)
List<int> types = _typeNumbers.ToList();
types.RemoveAt(0); // remove -1 from beginning of list
_sectionList = SqlReader.GetSectionsDataFromSQLite(types, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(types, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);

// filter by search pattern
_filteredlist = new List<string>();
Expand Down Expand Up @@ -1086,7 +1087,7 @@ public override void SetSelected(int i, int j)


// section list with selected types (only types in selected type)
_sectionList = SqlReader.GetSectionsDataFromSQLite(types, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_sectionList = SqlReader.Instance.GetSectionsDataFromSQLite(types, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);

// filter by search pattern
_filteredlist = new List<string>();
Expand Down Expand Up @@ -1167,6 +1168,11 @@ public override void SetSelected(int i, int j)
}
}

private Tuple<List<string>, List<int>> GetTypesDataFromSQLite(int catalogueIndex, string filePath, bool inclSuperseeded)
{
return SqlReader.Instance.GetTypesDataFromSQLite2(catalogueIndex, filePath, inclSuperseeded);
}

public override void UpdateUIFromSelectedItems()
{
if (SelectedItems[0] == "Catalogue")
Expand All @@ -1179,7 +1185,7 @@ public override void UpdateUIFromSelectedItems()

_catalogueNames = _cataloguedata.Item1;
_catalogueNumbers = _cataloguedata.Item2;
_typedata = SqlReader.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typedata = SqlReader.Instance.GetTypesDataFromSQLite(_catalogueIndex, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"), _inclSS);
_typeNames = _typedata.Item1;
_typeNumbers = _typedata.Item2;

Expand Down
18 changes: 8 additions & 10 deletions GsaGH/Components/1_Properties/GetSectionDimensions.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.GsaAPI;
using GsaGH.Parameters;
using OasysGH;
using OasysGH.Components;
using OasysGH.Parameters;
using OasysGH.Units.Helpers;
using OasysGH.Units;
using OasysUnits.Units;
using OasysGH.Units.Helpers;
using OasysUnits;
using GsaGH.Helpers.GsaAPI;
using System.Globalization;
using OasysGH.Helpers;
using System.Collections.Generic;
using System.IO;
using GsaGH.Helpers;
using GsaGH.Helpers.GH;
using OasysUnits.Units;

namespace GsaGH.Components
{
Expand Down Expand Up @@ -428,7 +426,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
else if (profile.StartsWith("CAT"))
{
string prof = profile.Split(' ')[2];
List<double> sqlValues = SqlReader.GetCatalogueProfileValues(prof, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
List<double> sqlValues = SqlReader.Instance.GetCatalogueProfileValues(prof, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
unit = LengthUnit.Meter;

DA.SetData(i++, new GH_UnitNumber(new Length(sqlValues[0], unit).ToUnit(this.LengthUnit))); //Depth
Expand Down
2 changes: 1 addition & 1 deletion GsaGH/Components/2_Geometry/SectionAlignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
else if (profile.StartsWith("CAT"))
{
string prof = profile.Split(' ')[2];
List<double> sqlValues = SqlReader.GetCatalogueProfileValues(prof, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
List<double> sqlValues = SqlReader.Instance.GetCatalogueProfileValues(prof, Path.Combine(AddReferencePriority.InstallPath, "sectlib.db3"));
unit = LengthUnit.Meter;

depth = new Length(sqlValues[0], unit);
Expand Down
9 changes: 3 additions & 6 deletions GsaGH/GsaGH.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/arup-group/GSA-Grasshopper</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>GSALogo128.png</PackageIcon>
<Version>0.9.39-beta</Version>
<Version>0.9.40-beta</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Description>Official Oasys GSA Grasshopper Plugin
Expand Down Expand Up @@ -44,11 +44,12 @@ Copyright © Oasys 1985 - 2022</Description>
<PackageReference Include="Grasshopper" Version="6.27.20176.5001" IncludeAssets="compile;build">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="OasysGH" Version="0.4.5-beta" />
<PackageReference Include="OasysGH" Version="0.5.0-beta" />
<PackageReference Include="RhinoCommon" Version="6.27.20176.5001">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile;build</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Data.SQLite" Version="1.0.117" />
</ItemGroup>

<ItemGroup>
Expand All @@ -65,10 +66,6 @@ Copyright © Oasys 1985 - 2022</Description>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.SQLite">
<HintPath>..\..\..\..\..\..\Program Files\Oasys\GSA 10.1\System.Data.SQLite.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
Expand Down
13 changes: 4 additions & 9 deletions GsaGH/GsaGHInfo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.IO;
using System.Collections.ObjectModel;
using Grasshopper.Kernel;
using System.Reflection;
using System.Net;
using System.Diagnostics;
using GsaGH.Helpers;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using Grasshopper.Kernel;
using OasysGH;
using OasysGH.Helpers;
using System.Runtime.InteropServices;

namespace GsaGH
{
Expand Down Expand Up @@ -209,7 +204,7 @@ public class GsaGHInfo : GH_AssemblyInfo
internal const string Company = "Oasys";
internal const string Copyright = "Copyright © Oasys 1985 - 2023";
internal const string Contact = "https://www.oasys-software.com/";
internal const string Vers = "0.9.39";
internal const string Vers = "0.9.40";
internal static bool isBeta = true;
internal static string Disclaimer = PluginName + " is pre-release and under active development, including further testing to be undertaken. It is provided \"as-is\" and you bear the risk of using it. Future versions may contain breaking changes. Any files, results, or other types of output information created using " + PluginName + " should not be relied upon without thorough and independent checking. ";
internal const string ProductName = "GSA";
Expand Down
Loading

0 comments on commit e742801

Please sign in to comment.