Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
NATSUME Hiroaki committed Dec 19, 2024
1 parent 9e15521 commit 2070904
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
19 changes: 11 additions & 8 deletions Tunny/Component/Operation/ConstructFishEggByCsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Tunny.Component.Operation
{
public partial class ConstructFishEggByCsv : GH_Component
public class ConstructFishEggByCsv : GH_Component
{
private readonly List<FishEgg> _fishEggs = new List<FishEgg>();
public override GH_Exposure Exposure => GH_Exposure.secondary;
Expand Down Expand Up @@ -63,14 +63,17 @@ private static Dictionary<string, double[]> GetVariableRange(List<VariableBase>
foreach (VariableBase variable in variables)
{
string name = variable.NickName;
switch (variable)
if (variable is NumberVariable numberVariable)
{
case NumberVariable number:
variableRange.Add(name, new double[] { number.LowerBond, number.UpperBond });
break;
case CategoricalVariable _:
variableRange.Add(name, Array.Empty<double>());
break;
variableRange.Add(name, new double[] { numberVariable.LowerBond, numberVariable.UpperBond });
}
else if (variable is CategoricalVariable)
{
variableRange.Add(name, Array.Empty<double>());
}
else
{
throw new InvalidOperationException("Variable type is not supported.");
}
}
return variableRange;
Expand Down
19 changes: 15 additions & 4 deletions Tunny/Type/FishEgg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ namespace Tunny.Type
[Serializable]
public class FishEgg
{
private readonly bool _skipIfExist;
private readonly Dictionary<string, string> _paramDict;
private readonly Dictionary<string, string> _attrDict;
private bool _skipIfExist;
private Dictionary<string, string> _paramDict;
private Dictionary<string, string> _attrDict;

public FishEgg(bool skipIfExist = true)
public FishEgg()
{
TLog.MethodStart();
Initialize(true);
}

public FishEgg(bool skipIfExist)
{
TLog.MethodStart();
Initialize(skipIfExist);
}

private void Initialize(bool skipIfExist)
{
_skipIfExist = skipIfExist;
_paramDict = new Dictionary<string, string>();
_attrDict = new Dictionary<string, string>();
Expand Down

0 comments on commit 2070904

Please sign in to comment.