Fix repository clone strategy
This commit is contained in:
@@ -63,6 +63,9 @@
|
|||||||
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs">
|
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Windows\CalculationWindows\CalculatorsViews\SelectResultsForExportView.xaml.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml.cs">
|
<Compile Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -227,6 +230,9 @@
|
|||||||
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml">
|
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculatorViews\GeometryCalculatorResultView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Update="Windows\CalculationWindows\CalculatorsViews\SelectResultsForExportView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml">
|
<Page Update="Windows\CalculationWindows\ProgressViews\ShowProgressView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using StructureHelper.Infrastructure;
|
using StructureHelper.Infrastructure;
|
||||||
using StructureHelper.Infrastructure.Enums;
|
using StructureHelper.Infrastructure.Enums;
|
||||||
using StructureHelper.Windows.CalculationWindows.ProgressViews;
|
using StructureHelper.Windows.CalculationWindows.ProgressViews;
|
||||||
|
using StructureHelper.Windows.Errors;
|
||||||
using StructureHelper.Windows.ViewModels;
|
using StructureHelper.Windows.ViewModels;
|
||||||
using StructureHelper.Windows.ViewModels.Errors;
|
using StructureHelper.Windows.ViewModels.Errors;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
@@ -115,6 +116,12 @@ namespace StructureHelper.Windows.BeamShears
|
|||||||
{
|
{
|
||||||
beamShearCalculator.Run();
|
beamShearCalculator.Run();
|
||||||
var result = beamShearCalculator.Result as IBeamShearCalculatorResult;
|
var result = beamShearCalculator.Result as IBeamShearCalculatorResult;
|
||||||
|
if (result.IsValid == false)
|
||||||
|
{
|
||||||
|
ErrorProcessor vm = ShowInvalidResult(result);
|
||||||
|
new ErrorMessage(vm).ShowDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
Window window = new BeamShearResultView(result);
|
Window window = new BeamShearResultView(result);
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
if (beamShearCalculator.ShowTraceData == true)
|
if (beamShearCalculator.ShowTraceData == true)
|
||||||
@@ -127,5 +134,14 @@ namespace StructureHelper.Windows.BeamShears
|
|||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ErrorProcessor ShowInvalidResult(IBeamShearCalculatorResult? result)
|
||||||
|
{
|
||||||
|
return new ErrorProcessor()
|
||||||
|
{
|
||||||
|
ShortText = "Result of calculation is not valid",
|
||||||
|
DetailText = $"{result.Description}"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||||
|
{
|
||||||
|
public class SelectResultSettings
|
||||||
|
{
|
||||||
|
public string Filename { get; set; } = string.Empty;
|
||||||
|
public bool ExportValidResults { get; set; }
|
||||||
|
public bool ExportInValidResults { get; set; }
|
||||||
|
public IEnumerable<IResult>? Results { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.SelectResultsForExportView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DataContext="{d:DesignInstance local:SelectResultsForExportViewModel}"
|
||||||
|
Title="Select results for export" Height="200" Width="300" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="40"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Margin="10,0,0,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Text="File name"/>
|
||||||
|
<TextBox Grid.Column="1" IsEnabled="False" Text="{Binding Filename}"/>
|
||||||
|
<CheckBox Grid.Row="1" Content="Valid results"/>
|
||||||
|
<CheckBox Grid.Row="2" Content="Invalid results"/>
|
||||||
|
<ContentControl Grid.Row="4" Grid.ColumnSpan="2" Margin="-10,0,0,0" ContentTemplate="{StaticResource ResultValidness}" Content="{Binding ValidResultCounter}"/>
|
||||||
|
</Grid>
|
||||||
|
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for SelectResultsForExportView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class SelectResultsForExportView : Window
|
||||||
|
{
|
||||||
|
private SelectResultsForExportViewModel viewModel;
|
||||||
|
public SelectResultsForExportView(SelectResultsForExportViewModel viewModel)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.viewModel = viewModel;
|
||||||
|
this.DataContext = this.viewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using StructureHelper.Windows.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||||
|
{
|
||||||
|
public class SelectResultsForExportViewModel : OkCancelViewModelBase
|
||||||
|
{
|
||||||
|
private readonly SelectResultSettings resultSettings;
|
||||||
|
|
||||||
|
public string Filename
|
||||||
|
{
|
||||||
|
get => resultSettings.Filename;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resultSettings.Filename = value;
|
||||||
|
OnPropertyChanged(nameof(Filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ExportValidResults
|
||||||
|
{
|
||||||
|
get => resultSettings.ExportValidResults;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resultSettings.ExportValidResults = value;
|
||||||
|
OnPropertyChanged(nameof(ExportValidResults));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool ExportInValidResults
|
||||||
|
{
|
||||||
|
get => resultSettings.ExportInValidResults;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resultSettings.ExportInValidResults = value;
|
||||||
|
OnPropertyChanged(nameof(ExportInValidResults));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ValidResultCounterVM ValidResultCounter {get;}
|
||||||
|
|
||||||
|
public SelectResultsForExportViewModel(SelectResultSettings resultSettings)
|
||||||
|
{
|
||||||
|
this.resultSettings = resultSettings;
|
||||||
|
ValidResultCounter = new(this.resultSettings.Results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock x:Name="HeaderText" TextWrapping="Wrap" Text="Happened something wrong" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" FontWeight="Bold"/>
|
<TextBlock x:Name="HeaderText" TextWrapping="Wrap" Text="Something wrong happened" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" FontWeight="Bold"/>
|
||||||
<TextBlock Grid.Row="1" x:Name="MainText" TextWrapping="Wrap" Text="{Binding ShortText}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
<TextBlock Grid.Row="1" x:Name="MainText" TextWrapping="Wrap" Text="{Binding ShortText}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -38,11 +38,10 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
{
|
{
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
|
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
|
||||||
PrepareNewResult();
|
PrepareNewResult();
|
||||||
//PrepareInputData();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InitializeStrategies();
|
InitializeStrategies();
|
||||||
if (CheckInputData() == false) { return;}
|
if (CheckInputData() == false) { return;}
|
||||||
|
try
|
||||||
|
{
|
||||||
CalculateResult();
|
CalculateResult();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -52,11 +51,6 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrepareInputData()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool CheckInputData()
|
private bool CheckInputData()
|
||||||
{
|
{
|
||||||
var checkResult = checkInputDataLogic.Check();
|
var checkResult = checkInputDataLogic.Check();
|
||||||
|
|||||||
@@ -3,11 +3,6 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
|||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Loggers;
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelperLogics.Models.BeamShears
|
namespace StructureHelperLogics.Models.BeamShears
|
||||||
{
|
{
|
||||||
@@ -18,7 +13,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
private IBeamShearSectionLogic beamShearSectionLogic;
|
private IBeamShearSectionLogic beamShearSectionLogic;
|
||||||
private List<IBeamShearActionResult> actionResults;
|
private List<IBeamShearActionResult> actionResults;
|
||||||
private IBeamShearCalculatorInputData inputData;
|
private IBeamShearCalculatorInputData inputData;
|
||||||
private List<CalcTerms> calcTerms = new() { CalcTerms.LongTerm, CalcTerms.ShortTerm };
|
private readonly List<CalcTerms> calcTerms = new() { CalcTerms.LongTerm, CalcTerms.ShortTerm };
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
|
|
||||||
@@ -166,13 +161,15 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
private List<IInclinedSection> GetInclinedSections(IBeamShearSection beamShearSection)
|
private List<IInclinedSection> GetInclinedSections(IBeamShearSection beamShearSection)
|
||||||
{
|
{
|
||||||
IGetInclinedSectionListInputData inclinedSectionInputDataLogic = new GetInclinedSectionListInputData(beamShearSection);
|
IGetInclinedSectionListInputData inclinedSectionInputDataLogic = new GetInclinedSectionListInputData(beamShearSection);
|
||||||
IGetInclinedSectionListLogic getInclinedSectionListLogic = new GetInclinedSectionListLogic(inclinedSectionInputDataLogic, TraceLogger);
|
//IGetInclinedSectionListLogic getInclinedSectionListLogic = new GetInclinedSectionListLogic(inclinedSectionInputDataLogic, TraceLogger);
|
||||||
|
IGetInclinedSectionListLogic getInclinedSectionListLogic = new GetInclinedSectionListLogic(inclinedSectionInputDataLogic, null);
|
||||||
return getInclinedSectionListLogic.GetInclinedSections();
|
return getInclinedSectionListLogic.GetInclinedSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IForceTuple GetForceTupleByShearAction(IBeamShearAction beamShearAction, IInclinedSection inclinedSection, LimitStates limitState, CalcTerms calcTerm)
|
private IForceTuple GetForceTupleByShearAction(IBeamShearAction beamShearAction, IInclinedSection inclinedSection, LimitStates limitState, CalcTerms calcTerm)
|
||||||
{
|
{
|
||||||
IGetDirectShearForceLogic getDirectShearForceLogic = new GetDirectShearForceLogic(beamShearAction, inclinedSection, limitState, calcTerm, TraceLogger);
|
//IGetDirectShearForceLogic getDirectShearForceLogic = new GetDirectShearForceLogic(beamShearAction, inclinedSection, limitState, calcTerm, TraceLogger);
|
||||||
|
IGetDirectShearForceLogic getDirectShearForceLogic = new GetDirectShearForceLogic(beamShearAction, inclinedSection, limitState, calcTerm, null);
|
||||||
return getDirectShearForceLogic.CalculateShearForceTuple();
|
return getDirectShearForceLogic.CalculateShearForceTuple();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.Models.BeamShears
|
||||||
|
{
|
||||||
|
internal class BeamShearCalculatorCloneStrategy : ICloneStrategy<IBeamShearCalculator>
|
||||||
|
{
|
||||||
|
private readonly ICloningStrategy cloningStrategy;
|
||||||
|
private IUpdateStrategy<IBeamShearCalculator> updateStrategy;
|
||||||
|
private ICloneStrategy<IBeamShearCalculatorInputData> inputDataCloningStrategy;
|
||||||
|
public BeamShearCalculatorCloneStrategy(ICloningStrategy cloningStrategy)
|
||||||
|
{
|
||||||
|
this.cloningStrategy = cloningStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBeamShearCalculator GetClone(IBeamShearCalculator sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(cloningStrategy);
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
InitializeStrategies();
|
||||||
|
BeamShearCalculator calculator = new(Guid.NewGuid());
|
||||||
|
updateStrategy.Update(calculator, sourceObject);
|
||||||
|
calculator.InputData = inputDataCloningStrategy.GetClone(sourceObject.InputData);
|
||||||
|
return calculator;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeStrategies()
|
||||||
|
{
|
||||||
|
updateStrategy ??= new BeamShearCalculatorUpdateStrategy();
|
||||||
|
inputDataCloningStrategy ??= new BeamShearCalculatorInputDataCloneStrategy(cloningStrategy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.Models.BeamShears
|
||||||
|
{
|
||||||
|
internal class BeamShearCalculatorInputDataCloneStrategy : ICloneStrategy<IBeamShearCalculatorInputData>
|
||||||
|
{
|
||||||
|
private readonly ICloningStrategy cloningStrategy;
|
||||||
|
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
|
||||||
|
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
|
||||||
|
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||||
|
public BeamShearCalculatorInputDataCloneStrategy(ICloningStrategy cloningStrategy)
|
||||||
|
{
|
||||||
|
this.cloningStrategy = cloningStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBeamShearCalculatorInputData GetClone(IBeamShearCalculatorInputData sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(cloningStrategy);
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
InitializeStrategies();
|
||||||
|
BeamShearCalculatorInputData inputData = new(Guid.NewGuid());
|
||||||
|
actionUpdateStrategy.Update(inputData, sourceObject);
|
||||||
|
sectionUpdateStrategy.Update(inputData, sourceObject);
|
||||||
|
stirrupUpdateStrategy.Update(inputData, sourceObject);
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeStrategies()
|
||||||
|
{
|
||||||
|
actionUpdateStrategy ??= new HasActionsUpdateCloneStrategy(cloningStrategy);
|
||||||
|
sectionUpdateStrategy ??= new HasSectionsUpdateCloneStrategy(cloningStrategy);
|
||||||
|
stirrupUpdateStrategy ??= new HasStirrupsUpdateCloneStrategy(cloningStrategy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
|
||||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||||
//All rights reserved.
|
//All rights reserved.
|
||||||
@@ -11,6 +12,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
|
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
|
||||||
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
|
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
|
||||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||||
|
private IUpdateStrategy<IHasCalculators> calculatorUpdateStrategy;
|
||||||
private BeamShearRepository targetRepository;
|
private BeamShearRepository targetRepository;
|
||||||
|
|
||||||
public BeamShearRepositoryCloneStrategy(ICloningStrategy cloningStrategy)
|
public BeamShearRepositoryCloneStrategy(ICloningStrategy cloningStrategy)
|
||||||
@@ -24,6 +26,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
actionUpdateStrategy.Update(targetRepository, sourceObject);
|
actionUpdateStrategy.Update(targetRepository, sourceObject);
|
||||||
sectionUpdateStrategy.Update(targetRepository, sourceObject);
|
sectionUpdateStrategy.Update(targetRepository, sourceObject);
|
||||||
stirrupUpdateStrategy.Update(targetRepository, sourceObject);
|
stirrupUpdateStrategy.Update(targetRepository, sourceObject);
|
||||||
|
calculatorUpdateStrategy.Update(targetRepository, sourceObject);
|
||||||
return targetRepository;
|
return targetRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
|||||||
actionUpdateStrategy ??= new HasActionsUpdateCloneStrategy(cloningStrategy);
|
actionUpdateStrategy ??= new HasActionsUpdateCloneStrategy(cloningStrategy);
|
||||||
sectionUpdateStrategy ??= new HasSectionsUpdateCloneStrategy(cloningStrategy);
|
sectionUpdateStrategy ??= new HasSectionsUpdateCloneStrategy(cloningStrategy);
|
||||||
stirrupUpdateStrategy ??= new HasStirrupsUpdateCloneStrategy(cloningStrategy);
|
stirrupUpdateStrategy ??= new HasStirrupsUpdateCloneStrategy(cloningStrategy);
|
||||||
|
calculatorUpdateStrategy ??= new HasCalculatorsUpdateCloneStrategy(cloningStrategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.Models.BeamShears
|
||||||
|
{
|
||||||
|
internal class HasCalculatorsUpdateCloneStrategy : IUpdateStrategy<IHasCalculators>
|
||||||
|
{
|
||||||
|
private readonly ICloningStrategy cloningStrategy;
|
||||||
|
private ICloneStrategy<IBeamShearCalculator> beamShearCalculatorCloneStrategy;
|
||||||
|
|
||||||
|
public HasCalculatorsUpdateCloneStrategy(ICloningStrategy cloningStrategy)
|
||||||
|
{
|
||||||
|
this.cloningStrategy = cloningStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(cloningStrategy);
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
|
targetObject.Calculators.Clear();
|
||||||
|
foreach (var calculator in sourceObject.Calculators)
|
||||||
|
{
|
||||||
|
ICalculator newCalculator;
|
||||||
|
if (calculator is IBeamShearCalculator shearCalculator)
|
||||||
|
{
|
||||||
|
beamShearCalculatorCloneStrategy ??= new BeamShearCalculatorCloneStrategy(cloningStrategy);
|
||||||
|
newCalculator = beamShearCalculatorCloneStrategy.GetClone(shearCalculator);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(calculator));
|
||||||
|
}
|
||||||
|
targetObject.Calculators.Add(newCalculator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TraceLogger?.AddMessage("Longitudinal force N={LongitudinalForce}(N) is positive (tension)", TraceLogStatuses.Service);
|
TraceLogger?.AddMessage($"Longitudinal force N={LongitudinalForce}(N) is positive (tension)", TraceLogStatuses.Service);
|
||||||
return GetPosForceResult();
|
return GetPosForceResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user