diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
index e991a30..5cac7d1 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
@@ -1,15 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.Units;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs b/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
index 44fa13d..e4958d1 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
diff --git a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs
index c0504ef..9523ad0 100644
--- a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs
+++ b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs
@@ -1,7 +1,6 @@
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
diff --git a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
index e83a190..931a22b 100644
--- a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
+++ b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
@@ -1,24 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Windows;
-using System.Windows.Documents;
+using StructureHelper.Models.Materials;
+using StructureHelper.Services.Primitives;
+using StructureHelper.Windows.MainWindow;
+using StructureHelper.Windows.ViewModels.NdmCrossSections;
+using StructureHelperLogics.NdmCalculations.Primitives;
using System.Windows.Input;
using System.Windows.Media;
-using StructureHelper.Infrastructure.Enums;
-using StructureHelper.Infrastructure.UI.Converters.Units;
-using StructureHelper.Models.Materials;
-using StructureHelper.Services.Primitives;
-using StructureHelper.UnitSystem.Systems;
-using StructureHelper.Windows.MainWindow;
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperLogics.Models.Materials;
-using StructureHelperCommon.Services.ColorServices;
-using StructureHelperLogics.Models.Primitives;
-using System.Windows.Controls;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using StructureHelper.Windows.ViewModels.NdmCrossSections;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
diff --git a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs
index 74f5b55..ff76ad7 100644
--- a/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs
+++ b/StructureHelper/Infrastructure/UI/DataContexts/PrimitiveOperations.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
diff --git a/StructureHelper/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs b/StructureHelper/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
index 8a47f00..3f08950 100644
--- a/StructureHelper/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
+++ b/StructureHelper/Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
@@ -1,14 +1,5 @@
-using StructureHelper.Infrastructure.Enums;
-using StructureHelper.UnitSystem.Systems;
-using StructureHelper.Windows.MainWindow;
-using StructureHelperLogics.Models.Materials;
-using StructureHelperCommon.Models.Shapes;
-using System;
-using StructureHelperLogics.Models.Primitives;
+using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
-using StructureHelper.Windows.ViewModels.NdmCrossSections;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
index c3744c2..43d2ac8 100644
--- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
@@ -49,5 +49,10 @@
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Services/Exports/ExportToFileService.cs b/StructureHelper/Services/Exports/ExportToFileService.cs
index a6bb77b..d2d4e2c 100644
--- a/StructureHelper/Services/Exports/ExportToFileService.cs
+++ b/StructureHelper/Services/Exports/ExportToFileService.cs
@@ -1,6 +1,6 @@
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Errors;
-using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
diff --git a/StructureHelper/Services/Settings/GlobalRepository.cs b/StructureHelper/Services/Settings/GlobalRepository.cs
new file mode 100644
index 0000000..b0ac354
--- /dev/null
+++ b/StructureHelper/Services/Settings/GlobalRepository.cs
@@ -0,0 +1,25 @@
+using StructureHelper.Models.Materials;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Repositories;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Services.Settings
+{
+ internal static class GlobalRepository
+ {
+ private static IDataRepository materials;
+ public static IDataRepository Materials
+ {
+ get
+ {
+ materials ??= new ListRepository(new MaterialUpdateStrategy());
+ return materials;
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/MainWindow/MainViewModel.cs b/StructureHelper/Windows/MainWindow/MainViewModel.cs
index 8a1dc04..4138bf8 100644
--- a/StructureHelper/Windows/MainWindow/MainViewModel.cs
+++ b/StructureHelper/Windows/MainWindow/MainViewModel.cs
@@ -2,6 +2,7 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
+using StructureHelper.Services.Settings;
using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
using StructureHelper.Windows.ViewModels;
@@ -10,7 +11,6 @@ using StructureHelper.Windows.ViewModels.Materials;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
@@ -403,6 +403,10 @@ namespace StructureHelper.Windows.MainWindow
item.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
}
PrimitiveLogic.Refresh();
+ foreach (var item in newRepository.HeadMaterials)
+ {
+ GlobalRepository.Materials.Create(item);
+ }
return primitives;
}
return new List();
diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml
index 39cc35e..a7b7df8 100644
--- a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml
+++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml
@@ -14,7 +14,12 @@
-
+
+
+
+
+
+
@@ -46,4 +51,6 @@
+
+
diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs
index e6bf8c8..f4f8c65 100644
--- a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs
+++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs
@@ -1,7 +1,6 @@
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
@@ -31,7 +30,10 @@ namespace StructureHelper.Windows.MainWindow.Materials
{
InitializeComponent();
this.headMaterial = headMaterial;
- vm = new HeadMaterialViewModel(this.headMaterial);
+ vm = new HeadMaterialViewModel(this.headMaterial)
+ {
+ ParentWindow = this
+ };
DataContext = vm;
AddDataTemplates();
}
diff --git a/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/CircleView.xaml b/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/CircleView.xaml
index 4da1b97..d1832c6 100644
--- a/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/CircleView.xaml
+++ b/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/CircleView.xaml
@@ -9,7 +9,7 @@
-
+
@@ -33,9 +33,6 @@
-
-
-
-
+
diff --git a/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/RectangleBeamView.xaml b/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/RectangleBeamView.xaml
index 3bc67bd..be6d691 100644
--- a/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/RectangleBeamView.xaml
+++ b/StructureHelper/Windows/PrimitiveTemplates/RCs/Beams/RectangleBeamView.xaml
@@ -14,7 +14,7 @@
-
+
@@ -42,9 +42,6 @@
-
-
-
-
+
diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs
index 9ecadf6..5fb2c36 100644
--- a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs
@@ -1,22 +1,14 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
-using StructureHelper.Services.Primitives;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
-using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
-using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
index fa6a55c..de66dd7 100644
--- a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
@@ -18,7 +18,6 @@ using StructureHelper.Windows.ViewModels.Graphs;
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
@@ -32,8 +31,6 @@ using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
index fcf6d21..61c29f5 100644
--- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
@@ -1,7 +1,6 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
diff --git a/StructureHelper/Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs
index 154352d..a92dfae 100644
--- a/StructureHelper/Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs
@@ -1,6 +1,5 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
diff --git a/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs
index 4989a33..f8dea99 100644
--- a/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs
@@ -3,7 +3,6 @@ using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
diff --git a/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs
index b2b9676..25bbd66 100644
--- a/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs
@@ -2,7 +2,6 @@
using StructureHelper.Models.Materials;
using StructureHelper.Windows.AddMaterialWindow;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Materials;
@@ -16,7 +15,7 @@ using System.Windows.Media;
namespace StructureHelper.Windows.ViewModels.Materials
{
- internal class HeadMaterialViewModel : ViewModelBase
+ internal class HeadMaterialViewModel : OkCancelViewModelBase
{
IHeadMaterial headMaterial;
HelperMaterialViewModel helperMaterialViewModel;
diff --git a/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs
index a01b3bc..11614c6 100644
--- a/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs
@@ -1,9 +1,9 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials;
+using StructureHelper.Services.Settings;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using System.Linq;
@@ -42,6 +42,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
else if (paramType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
else if (paramType == MaterialType.GlassFiber) { AddGlassFiber(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(paramType)}");
+ GlobalRepository.Materials.Create(NewItem);
base.AddMethod(parameter);
}
public override void DeleteMethod(object parameter)
@@ -57,15 +58,35 @@ namespace StructureHelper.Windows.ViewModels.Materials
var dialogResult = MessageBox.Show("Delete material?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
+ GlobalRepository.Materials.Delete(SelectedItem.Id);
base.DeleteMethod(parameter);
}
}
public override void EditMethod(object parameter)
{
+ var copyObject = GlobalRepository.Materials.GetById(SelectedItem.Id).Clone() as IHeadMaterial;
var wnd = new HeadMaterialView(SelectedItem);
wnd.ShowDialog();
+ if (wnd.DialogResult == true)
+ {
+ GlobalRepository.Materials.Update(SelectedItem);
+ }
+ else
+ {
+ var updateStrategy = new MaterialUpdateStrategy();
+ updateStrategy.Update(SelectedItem, copyObject);
+ }
base.EditMethod(parameter);
}
+ public override void CopyMethod(object parameter)
+ {
+ NewItem = SelectedItem.Clone() as IHeadMaterial;
+ NewItem.Name = $"{NewItem.Name} copy";
+ GlobalRepository.Materials.Create(NewItem);
+ Collection.Add(NewItem);
+ Items.Add(NewItem);
+ SelectedItem = NewItem;
+ }
private void AddElastic()
{
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Elastic200);
diff --git a/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs
index 62d0b4a..a5fc79c 100644
--- a/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
index 61bfac1..bf1f3c2 100644
--- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
+++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
@@ -13,7 +13,6 @@ using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.Models.Primitives;
-using StructureHelperCommon.Infrastructures.Strings;
using ViewModelBase = StructureHelper.Infrastructure.ViewModelBase;
using System.Windows.Forms;
using System.Windows.Documents;
diff --git a/StructureHelper/Windows/ViewModels/OkCancelViewModelBase.cs b/StructureHelper/Windows/ViewModels/OkCancelViewModelBase.cs
index efd31b6..d13a129 100644
--- a/StructureHelper/Windows/ViewModels/OkCancelViewModelBase.cs
+++ b/StructureHelper/Windows/ViewModels/OkCancelViewModelBase.cs
@@ -1,12 +1,4 @@
using StructureHelper.Infrastructure;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperCommon.Models.Forces;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
diff --git a/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs b/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs
index 50acc97..133e353 100644
--- a/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs
@@ -4,7 +4,6 @@ using StructureHelper.Models.Materials;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.CrossSections;
diff --git a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs b/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs
similarity index 96%
rename from StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
rename to StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs
index fa1299b..a1df238 100644
--- a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
+++ b/StructureHelperCommon/Infrastructures/Exceptions/ErrorString.cs
@@ -1,4 +1,4 @@
-namespace StructureHelperCommon.Infrastructures.Strings
+namespace StructureHelperCommon.Infrastructures.Exceptions
{
public static class ErrorStrings
{
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IDataRepository.cs b/StructureHelperCommon/Infrastructures/Interfaces/IDataRepository.cs
index d8dde3d..6cced0d 100644
--- a/StructureHelperCommon/Infrastructures/Interfaces/IDataRepository.cs
+++ b/StructureHelperCommon/Infrastructures/Interfaces/IDataRepository.cs
@@ -8,8 +8,10 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IDataRepository
{
- void Save(T entity);
- T Load(Guid Id);
-
+ void Create(T entity);
+ void Update(T entity);
+ void Delete(Guid Id);
+ T GetById(Guid Id);
+ List GetAll();
}
}
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs b/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs
index 29ba150..02968da 100644
--- a/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs
+++ b/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs
@@ -8,6 +8,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
/// Unique identifier
///
Guid Id { get;}
- void Save();
+ //void Save();
}
}
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IUpdateStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/IUpdateStrategy.cs
new file mode 100644
index 0000000..cdec094
--- /dev/null
+++ b/StructureHelperCommon/Infrastructures/Interfaces/IUpdateStrategy.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Infrastructures.Interfaces
+{
+ public interface IUpdateStrategy
+ {
+ void Update(T targetObject, T sourceObject);
+ }
+}
diff --git a/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs b/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs
index 5292cbb..dd0b830 100644
--- a/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs
+++ b/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelperCommon.Models.Forces
{
diff --git a/StructureHelperCommon/Models/Forces/Factories/ForceCombinationListFactory.cs b/StructureHelperCommon/Models/Forces/Factories/ForceCombinationListFactory.cs
index 003a9c5..1d84713 100644
--- a/StructureHelperCommon/Models/Forces/Factories/ForceCombinationListFactory.cs
+++ b/StructureHelperCommon/Models/Forces/Factories/ForceCombinationListFactory.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelperCommon.Models.Forces
{
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Factories/ConcreteFactorsFactory.cs b/StructureHelperCommon/Models/Materials/Libraries/Factories/ConcreteFactorsFactory.cs
index 211136b..76ae377 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/Factories/ConcreteFactorsFactory.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/Factories/ConcreteFactorsFactory.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelperCommon.Models.Materials.Libraries
{
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Factories/FRFactorsFactory.cs b/StructureHelperCommon/Models/Materials/Libraries/Factories/FRFactorsFactory.cs
index e76eea6..107e08e 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/Factories/FRFactorsFactory.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/Factories/FRFactorsFactory.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs b/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
index c61d34c..c921a30 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
@@ -4,7 +4,6 @@ using System.Linq;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Codes;
namespace StructureHelperCommon.Models.Materials.Libraries
@@ -177,7 +176,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries
new ConcreteMaterialEntity(new Guid("2f5b70b9-f4c1-470d-ac27-a39a7093b6ea"))
{
CodeType = codeType,
- Code = code,
Name = "B30",
MainStrength = 30e6
},
diff --git a/StructureHelperCommon/Models/Materials/Libraries/IMaterialSafetyFactor.cs b/StructureHelperCommon/Models/Materials/Libraries/IMaterialSafetyFactor.cs
index 40fecef..dc93baa 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/IMaterialSafetyFactor.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/IMaterialSafetyFactor.cs
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperCommon.Models.Materials.Libraries
{
- public interface IMaterialSafetyFactor : ICloneable
+ public interface IMaterialSafetyFactor : ISaveable, ICloneable
{
string Name { get; set; }
bool Take { get; set; }
diff --git a/StructureHelperCommon/Models/Materials/Libraries/IPartialFactor.cs b/StructureHelperCommon/Models/Materials/Libraries/IPartialFactor.cs
index 1f4696f..12de691 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/IPartialFactor.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/IPartialFactor.cs
@@ -1,8 +1,9 @@
-using System;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
namespace StructureHelperCommon.Models.Materials.Libraries
{
- public interface IPartialFactor : ICloneable
+ public interface IPartialFactor : ISaveable, ICloneable
{
double FactorValue {get;set;}
}
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs
new file mode 100644
index 0000000..d2fcb37
--- /dev/null
+++ b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs
@@ -0,0 +1,20 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Materials.Libraries
+{
+ internal class MaterialPartialFactorUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(IMaterialPartialFactor targetObject, IMaterialPartialFactor sourceObject)
+ {
+ targetObject.LimitState = sourceObject.LimitState;
+ targetObject.StressState = sourceObject.StressState;
+ targetObject.CalcTerm = sourceObject.CalcTerm;
+ targetObject.FactorValue = sourceObject.FactorValue;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs
new file mode 100644
index 0000000..700e091
--- /dev/null
+++ b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs
@@ -0,0 +1,24 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Materials.Libraries
+{
+ internal class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject)
+ {
+ targetObject.Name = sourceObject.Name;
+ targetObject.Take = sourceObject.Take;
+ targetObject.Description = sourceObject.Description;
+ targetObject.PartialFactors.Clear();
+ foreach (var item in sourceObject.PartialFactors)
+ {
+ targetObject.PartialFactors.Add(item.Clone() as IMaterialPartialFactor);
+ }
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs b/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs
index a73a227..960a412 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs
@@ -1,13 +1,13 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
+using System;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public class MaterialPartialFactor : IMaterialPartialFactor
{
private double factorValue;
-
+ public Guid Id { get; }
public StressStates StressState { get; set; }
public CalcTerms CalcTerm { get; set; }
public LimitStates LimitState { get; set; }
@@ -24,23 +24,24 @@ namespace StructureHelperCommon.Models.Materials.Libraries
}
}
- public MaterialPartialFactor()
+
+ public MaterialPartialFactor(Guid id)
{
+ Id = id;
StressState = StressStates.Compression;
LimitState = LimitStates.ULS;
CalcTerm = CalcTerms.LongTerm;
FactorValue = 1d;
}
+ public MaterialPartialFactor() : this (Guid.NewGuid())
+ { }
+
public object Clone()
{
- var newItem = new MaterialPartialFactor()
- {
- StressState = StressState,
- CalcTerm = CalcTerm,
- LimitState = LimitState,
- FactorValue = FactorValue,
- };
+ var newItem = new MaterialPartialFactor();
+ var updateStrategy = new MaterialPartialFactorUpdateStrategy();
+ updateStrategy.Update(newItem, this);
return newItem;
}
}
diff --git a/StructureHelperCommon/Models/Materials/Libraries/MaterialSafetyFactor.cs b/StructureHelperCommon/Models/Materials/Libraries/MaterialSafetyFactor.cs
index e8f6a71..adeab15 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/MaterialSafetyFactor.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/MaterialSafetyFactor.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using StructureHelperCommon.Infrastructures.Enums;
@@ -6,23 +7,32 @@ namespace StructureHelperCommon.Models.Materials.Libraries
{
public class MaterialSafetyFactor : IMaterialSafetyFactor
{
+ public Guid Id { get; }
public string Name {get; set; }
public bool Take { get; set; }
public string Description { get; set; }
public List PartialFactors { get; }
- public MaterialSafetyFactor()
+
+ public MaterialSafetyFactor(Guid id)
{
+ Id = id;
Take = true;
Name = "New factor";
Description = "Material safety factor for ...";
PartialFactors = new List();
}
+ public MaterialSafetyFactor() : this (Guid.NewGuid())
+ { }
+
public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates)
{
double result = 1d;
- var coefficients = PartialFactors.Where(x => (x.StressState == stressState & x.CalcTerm == calcTerm & x.LimitState == limitStates));
+ var coefficients = PartialFactors
+ .Where(x => x.StressState == stressState
+ & x.CalcTerm == calcTerm
+ & x.LimitState == limitStates);
foreach (var item in coefficients) { result *= item.FactorValue;}
return result;
}
@@ -30,13 +40,8 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public object Clone()
{
var newItem = new MaterialSafetyFactor();
- newItem.Take = Take;
- newItem.Name = Name;
- newItem.Description = Description;
- foreach (var item in PartialFactors)
- {
- newItem.PartialFactors.Add(item.Clone() as IMaterialPartialFactor);
- }
+ var updateSrategy = new MaterialSafetyFactorUpdateStrategy();
+ updateSrategy.Update(newItem, this);
return newItem;
}
}
diff --git a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
index d340774..a84e7dd 100644
--- a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
+++ b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/StructureHelperCommon/Models/Repositories/ListRepository.cs b/StructureHelperCommon/Models/Repositories/ListRepository.cs
new file mode 100644
index 0000000..17694e1
--- /dev/null
+++ b/StructureHelperCommon/Models/Repositories/ListRepository.cs
@@ -0,0 +1,58 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Repositories
+{
+ public class ListRepository : IDataRepository
+ where T : ISaveable
+ {
+ List internalData;
+ private IUpdateStrategy updateStrategy;
+ public void Create(T entity)
+ {
+ var isExists = internalData.Exists(x => x.Id == entity.Id);
+ if (isExists == true)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $":\nobject with Id={entity.Id} already exists");
+ }
+ internalData.Add(entity);
+ }
+
+ public void Delete(Guid Id)
+ {
+ T existingObject = GetById(Id);
+ internalData.Remove(existingObject);
+ }
+
+ public List GetAll()
+ {
+ return new List(internalData);
+ }
+
+ public T GetById(Guid id)
+ {
+ T existingObject = internalData.Single(x => x.Id == id);
+ return existingObject;
+ }
+
+ public void Update(T updateObject)
+ {
+ T existingObject = GetById(updateObject.Id);
+ updateStrategy.Update(existingObject, updateObject);
+ }
+ public ListRepository(List initialData, IUpdateStrategy updateStrategy)
+ {
+ internalData = initialData;
+ this.updateStrategy = updateStrategy;
+ }
+ public ListRepository(IUpdateStrategy updateStrategy) : this(new List(), updateStrategy)
+ {
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Forces/ForceActionService.cs b/StructureHelperCommon/Services/Forces/ForceActionService.cs
index d854de1..4d34c73 100644
--- a/StructureHelperCommon/Services/Forces/ForceActionService.cs
+++ b/StructureHelperCommon/Services/Forces/ForceActionService.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using System;
diff --git a/StructureHelperCommon/Services/Forces/ForceTupleService.cs b/StructureHelperCommon/Services/Forces/ForceTupleService.cs
index e1f21bf..b20eee9 100644
--- a/StructureHelperCommon/Services/Forces/ForceTupleService.cs
+++ b/StructureHelperCommon/Services/Forces/ForceTupleService.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
diff --git a/StructureHelperCommon/Services/Units/CommonOperation.cs b/StructureHelperCommon/Services/Units/CommonOperation.cs
index fe7bb6b..55470ea 100644
--- a/StructureHelperCommon/Services/Units/CommonOperation.cs
+++ b/StructureHelperCommon/Services/Units/CommonOperation.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
diff --git a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
index d06be37..b754396 100644
--- a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
@@ -32,7 +32,10 @@ namespace StructureHelperLogics.Models.Materials
public object Clone()
{
- return new ConcreteLibMaterial() { MaterialEntity = MaterialEntity, TensionForULS = TensionForULS, TensionForSLS = TensionForSLS };
+ var newItem = new ConcreteLibMaterial();
+ var updateStrategy = new ConcreteLibUpdateStrategy();
+ updateStrategy.Update(newItem, this);
+ return newItem;
}
public LM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
diff --git a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs
index 2d0fbf5..72a09d3 100644
--- a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs
@@ -31,7 +31,10 @@ namespace StructureHelperLogics.Models.Materials
public object Clone()
{
- return new ElasticMaterial() { Modulus = Modulus, CompressiveStrength = CompressiveStrength, TensileStrength = TensileStrength };
+ var newItem = new ElasticMaterial();
+ var updateStrategy = new ElasticUpdateStrategy();
+ updateStrategy.Update(newItem, this);
+ return newItem;
}
}
}
diff --git a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs
index 6a239a5..b3dd2b0 100644
--- a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs
@@ -48,14 +48,9 @@ namespace StructureHelperLogics.Models.Materials
public object Clone()
{
- var newItem = new FRMaterial(materialType)
- {
- Modulus = Modulus,
- CompressiveStrength = CompressiveStrength,
- TensileStrength = TensileStrength,
- ULSConcreteStrength = ULSConcreteStrength,
- SumThickness = SumThickness,
- };
+ var newItem = new FRMaterial(this.materialType);
+ var updateStrategy = new FRUpdateStrategy();
+ updateStrategy.Update(newItem, this);
return newItem;
}
diff --git a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs
index 9d02a9b..f64d469 100644
--- a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs
+++ b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs
@@ -2,7 +2,6 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
diff --git a/StructureHelperLogics/Models/Materials/Factories/PartialCoefficientFactory.cs b/StructureHelperLogics/Models/Materials/Factories/PartialCoefficientFactory.cs
index 966e295..a4a5165 100644
--- a/StructureHelperLogics/Models/Materials/Factories/PartialCoefficientFactory.cs
+++ b/StructureHelperLogics/Models/Materials/Factories/PartialCoefficientFactory.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
@@ -9,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials
-{
+{
public static class PartialCoefficientFactory
{
public static List GetDefaultConcreteSafetyFactors(CodeTypes codeType)
diff --git a/StructureHelperLogics/Models/Materials/HeadMaterial.cs b/StructureHelperLogics/Models/Materials/HeadMaterial.cs
index 3572f22..bff8015 100644
--- a/StructureHelperLogics/Models/Materials/HeadMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/HeadMaterial.cs
@@ -50,13 +50,11 @@ namespace StructureHelper.Models.Materials
public object Clone()
{
- IHeadMaterial material = new HeadMaterial
- {
- Name = Name,
- Color = Color,
- HelperMaterial = HelperMaterial.Clone() as IHelperMaterial
- };
- return material;
+ var newItem = new HeadMaterial();
+ newItem.HelperMaterial = this.HelperMaterial.Clone() as IHelperMaterial;
+ var updateStrategy = new MaterialUpdateStrategy();
+ updateStrategy.Update(newItem, this);
+ return newItem;
}
public void Save()
diff --git a/StructureHelperLogics/Models/Materials/IHeadMaterial.cs b/StructureHelperLogics/Models/Materials/IHeadMaterial.cs
index 7ff7acf..670eb4a 100644
--- a/StructureHelperLogics/Models/Materials/IHeadMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/IHeadMaterial.cs
@@ -16,7 +16,6 @@ namespace StructureHelper.Models.Materials
string Name { get; set; }
Color Color { get; set; }
IHelperMaterial HelperMaterial { get; set; }
- //MaterialDefinitionBase Material { get; set; }
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
}
}
diff --git a/StructureHelperLogics/Models/Materials/LibMaterial.cs b/StructureHelperLogics/Models/Materials/LibMaterial.cs
index f89657d..e1f41f7 100644
--- a/StructureHelperLogics/Models/Materials/LibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/LibMaterial.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using System.Collections.Generic;
using LCM = LoaderCalculator.Data.Materials;
diff --git a/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs
new file mode 100644
index 0000000..18d5a4d
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs
@@ -0,0 +1,21 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ internal class ConcreteLibUpdateStrategy : IUpdateStrategy
+ {
+ LibMaterialUpdateStrategy libUpdateStrategy = new LibMaterialUpdateStrategy();
+ public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject)
+ {
+ libUpdateStrategy.Update(targetObject, sourceObject);
+ targetObject.TensionForULS = sourceObject.TensionForULS;
+ targetObject.TensionForSLS = sourceObject.TensionForSLS;
+ targetObject.Humidity = sourceObject.Humidity;
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/Logics/ConcreteMaterialOptionLogic.cs b/StructureHelperLogics/Models/Materials/Logics/ConcreteMaterialOptionLogic.cs
index bebf94b..a508648 100644
--- a/StructureHelperLogics/Models/Materials/Logics/ConcreteMaterialOptionLogic.cs
+++ b/StructureHelperLogics/Models/Materials/Logics/ConcreteMaterialOptionLogic.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders;
using System;
using System.Collections.Generic;
diff --git a/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs
new file mode 100644
index 0000000..75db474
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs
@@ -0,0 +1,20 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ internal class ElasticUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(IElasticMaterial targetObject, IElasticMaterial sourceObject)
+ {
+ targetObject.Modulus = sourceObject.Modulus;
+ targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
+ targetObject.TensileStrength = sourceObject.TensileStrength;
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs
new file mode 100644
index 0000000..bcb283e
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs
@@ -0,0 +1,22 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ internal class FRUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(IFRMaterial targetObject, IFRMaterial sourceObject)
+ {
+ targetObject.Modulus = sourceObject.Modulus;
+ targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
+ targetObject.TensileStrength = targetObject.TensileStrength;
+ targetObject.ULSConcreteStrength = targetObject.ULSConcreteStrength;
+ targetObject.SumThickness = targetObject.SumThickness;
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs
new file mode 100644
index 0000000..8c379ac
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs
@@ -0,0 +1,23 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Materials.Libraries;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ internal class LibMaterialUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
+ {
+ targetObject.MaterialEntity = sourceObject.MaterialEntity;
+ targetObject.SafetyFactors.Clear();
+ foreach (var item in sourceObject.SafetyFactors)
+ {
+ targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
+ }
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs
new file mode 100644
index 0000000..4ab4756
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs
@@ -0,0 +1,89 @@
+using StructureHelper.Models.Materials;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ public class MaterialUpdateStrategy : IUpdateStrategy
+ {
+ public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
+ {
+ targetObject.Name = sourceObject.Name;
+ targetObject.Color = sourceObject.Color;
+ targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
+ UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial);
+ }
+
+ private static void UpdateHelperMaterial(IHelperMaterial target, IHelperMaterial source)
+ {
+ Check(target, source);
+ UpdateMaterial(target, source);
+ }
+ private static void Check(IHelperMaterial target, IHelperMaterial source)
+ {
+ if (target.GetType() != source.GetType())
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"target type is {target.GetType()}, \n is no coinside with source type {source.GetType()}");
+ }
+ }
+ private static void UpdateMaterial(IHelperMaterial target, IHelperMaterial source)
+ {
+ if (source is ILibMaterial)
+ {
+ UpdateLibMaterial(target, source);
+ }
+ else if (source is IElasticMaterial)
+ {
+ UpdateElastic(target, source);
+ }
+ else if (source is IFRMaterial)
+ {
+ UpdateFR(target, source);
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(IHelperMaterial)},\n But was: {source.GetType()}");
+ }
+ }
+ private static void UpdateFR(IHelperMaterial target, IHelperMaterial source)
+ {
+ var targetMaterial = target as IFRMaterial;
+ var sourceMaterial = source as IFRMaterial;
+ var logic = new FRUpdateStrategy();
+ logic.Update(targetMaterial, sourceMaterial);
+ }
+ private static void UpdateElastic(IHelperMaterial target, IHelperMaterial source)
+ {
+ var targetMaterial = target as IElasticMaterial;
+ var sourceMaterial = source as IElasticMaterial;
+ var logic = new ElasticUpdateStrategy();
+ logic.Update(targetMaterial, sourceMaterial);
+ }
+ private static void UpdateLibMaterial(IHelperMaterial target, IHelperMaterial source)
+ {
+ if (source is IConcreteLibMaterial)
+ {
+ var targetMaterial = target as IConcreteLibMaterial;
+ var sourceMaterial = source as IConcreteLibMaterial;
+ var logic = new ConcreteLibUpdateStrategy();
+ logic.Update(targetMaterial, sourceMaterial);
+ }
+ else if (source is IReinforcementLibMaterial)
+ {
+ var targetMaterial = target as IReinforcementLibMaterial;
+ var sourceMaterial = source as IReinforcementLibMaterial;
+ var logic = new ReinforcementLibUpdateStrategy();
+ logic.Update(targetMaterial, sourceMaterial);
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(ILibMaterial)},\n But was: {source.GetType()}");
+ }
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs
new file mode 100644
index 0000000..a613295
--- /dev/null
+++ b/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs
@@ -0,0 +1,18 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.Models.Materials
+{
+ internal class ReinforcementLibUpdateStrategy : IUpdateStrategy
+ {
+ LibMaterialUpdateStrategy libUpdateStrategy = new LibMaterialUpdateStrategy();
+ public void Update(IReinforcementLibMaterial targetObject, IReinforcementLibMaterial sourceObject)
+ {
+ libUpdateStrategy.Update(targetObject, sourceObject);
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Materials/MaterialCommonOptionLogic.cs b/StructureHelperLogics/Models/Materials/MaterialCommonOptionLogic.cs
index 96e44b2..51f768d 100644
--- a/StructureHelperLogics/Models/Materials/MaterialCommonOptionLogic.cs
+++ b/StructureHelperLogics/Models/Materials/MaterialCommonOptionLogic.cs
@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
diff --git a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs
index 626223f..ac8e069 100644
--- a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs
@@ -9,6 +9,7 @@ using Loadermaterials = LoaderCalculator.Data.Materials;
using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
+
namespace StructureHelperLogics.Models.Materials
{
public class ReinforcementLibMaterial : IReinforcementLibMaterial
@@ -29,7 +30,10 @@ namespace StructureHelperLogics.Models.Materials
public object Clone()
{
- return new ReinforcementLibMaterial() { MaterialEntity = MaterialEntity};
+ var newItem = new ReinforcementLibMaterial();
+ var updateStrategy = new ReinforcementLibUpdateStrategy();
+ updateStrategy.Update(newItem, this);
+ return newItem;
}
public Loadermaterials.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ExportForceResultToCSVLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ExportForceResultToCSVLogic.cs
index f74ddb4..6ee683d 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ExportForceResultToCSVLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ExportForceResultToCSVLogic.cs
@@ -1,12 +1,5 @@
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System.Text;
-using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs
index 48158aa..b6bfe53 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs
@@ -2,7 +2,6 @@
using LoaderCalculator.Logics;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs b/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs
index 631aab6..325a601 100644
--- a/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs
+++ b/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs b/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs
index f97ee4a..e2705a9 100644
--- a/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/ReinforcementPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/ReinforcementPrimitive.cs
index 071f451..c53058f 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/ReinforcementPrimitive.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/ReinforcementPrimitive.cs
@@ -74,7 +74,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public void Save()
{
- repository.Save(this);
+ repository.Create(this);
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs b/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs
index b729485..66635dc 100644
--- a/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs
+++ b/StructureHelperLogics/NdmCalculations/Primitives/VisualProperty.cs
@@ -1,5 +1,4 @@
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs
index 344f3f4..d704477 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs
@@ -1,7 +1,6 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
index ae249fa..4a4647c 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs
@@ -1,8 +1,5 @@
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
-using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Triangulations
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs
index bf6c69f..909b000 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs
@@ -5,7 +5,6 @@ using System.Collections.Generic;
using LoaderCalculator.Data.Ndms.Transformations;
using LoaderCalculator.Data.Matrix;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
namespace StructureHelperLogics.NdmCalculations.Triangulations
{
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
index c6c6823..7ddf722 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs
@@ -1,9 +1,5 @@
-using System;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
-using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Triangulations
diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
index 909bc82..5d78e04 100644
--- a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
+++ b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs
@@ -1,15 +1,7 @@
-using System;
-using System.Collections.Generic;
-using LoaderCalculator.Data.Materials;
-using LoaderCalculator.Data.Materials.MaterialBuilders;
+using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
-using StructureHelperLogics.Models.Materials;
-using StructureHelperCommon.Models.Shapes;
-using StructureHelperLogics.Models.Primitives;
using StructureHelper.Models.Materials;
+using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Triangulations
diff --git a/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
index 1a61666..5b5a8a4 100644
--- a/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
+++ b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs
@@ -1,7 +1,6 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.Models.Calculations.CalculationProperties;