UpdateStrategy for Actions was added
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelper.Models.Materials;
|
using StructureHelper.Models.Materials;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperCommon.Models.Repositories;
|
using StructureHelperCommon.Models.Repositories;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using System;
|
using System;
|
||||||
@@ -13,6 +14,8 @@ namespace StructureHelper.Services.Settings
|
|||||||
internal static class GlobalRepository
|
internal static class GlobalRepository
|
||||||
{
|
{
|
||||||
private static IDataRepository<IHeadMaterial> materials;
|
private static IDataRepository<IHeadMaterial> materials;
|
||||||
|
private static IDataRepository<IAction> actions;
|
||||||
|
|
||||||
public static IDataRepository<IHeadMaterial> Materials
|
public static IDataRepository<IHeadMaterial> Materials
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -21,5 +24,13 @@ namespace StructureHelper.Services.Settings
|
|||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static IDataRepository<IAction> Actions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
actions ??= new ListRepository<IAction>(new ActionUpdateStrategy());
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
|
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
|
||||||
d:DataContext="{d:DesignInstance vm:ForceCombinationByFactorVM}"
|
d:DataContext="{d:DesignInstance vm:ForceCombinationByFactorVM}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Force Combination By Factor" Height="250" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
Title="Force Combination By Factor" Height="290" Width="350" MinHeight="290" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="95"/>
|
<RowDefinition Height="95"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="35"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!--ForceTemplates.xaml-->
|
<!--ForceTemplates.xaml-->
|
||||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
||||||
@@ -49,5 +50,6 @@
|
|||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ULSFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ULSFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace StructureHelper.Windows.Forces
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
viewModel = new ForceCombinationByFactorVM(forceCombination);
|
viewModel = new ForceCombinationByFactorVM(forceCombination);
|
||||||
DataContext = viewModel;
|
DataContext = viewModel;
|
||||||
|
viewModel.ParentWindow = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,18 @@
|
|||||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
|
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
|
||||||
d:DataContext="{d:DesignInstance vm:ForceCombinationViewModel}"
|
d:DataContext="{d:DesignInstance vm:ForceCombinationViewModel}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Force Combination" Height="250" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
|
Title="Force Combination" Height="350" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="95"/>
|
<RowDefinition Height="95"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="35"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!--ForceTemplates.xaml-->
|
<!--ForceTemplates.xaml-->
|
||||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
||||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=CombinationListTemplate}" Content="{Binding}"/>
|
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=CombinationListTemplate}" Content="{Binding}"/>
|
||||||
|
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -27,13 +27,11 @@ namespace StructureHelper.Windows.Forces
|
|||||||
viewModel = _viewModel;
|
viewModel = _viewModel;
|
||||||
DataContext = viewModel;
|
DataContext = viewModel;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
viewModel.ParentWindow = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForceCombinationView(IForceCombinationList combinationList)
|
public ForceCombinationView(IForceCombinationList combinationList) : this(new ForceCombinationViewModel(combinationList))
|
||||||
{
|
{
|
||||||
viewModel = new ForceCombinationViewModel(combinationList);
|
|
||||||
DataContext = viewModel;
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,6 +407,10 @@ namespace StructureHelper.Windows.MainWindow
|
|||||||
{
|
{
|
||||||
GlobalRepository.Materials.Create(item);
|
GlobalRepository.Materials.Create(item);
|
||||||
}
|
}
|
||||||
|
foreach (var item in newRepository.ForceActions)
|
||||||
|
{
|
||||||
|
GlobalRepository.Actions.Create(item);
|
||||||
|
}
|
||||||
return primitives;
|
return primitives;
|
||||||
}
|
}
|
||||||
return new List<PrimitiveBase>();
|
return new List<PrimitiveBase>();
|
||||||
|
|||||||
@@ -15,13 +15,12 @@
|
|||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition Width="120"/>
|
<ColumnDefinition Width="120"/>
|
||||||
<ColumnDefinition Width="280"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}" SelectionChanged="ListBox_SelectionChanged">
|
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -42,19 +41,7 @@
|
|||||||
</ListBox>
|
</ListBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Grid.Column="1">
|
<StackPanel Grid.Column="1">
|
||||||
<Button Content="New Concrete" Command="{Binding AddNewConcreteMaterialCommand}"/>
|
|
||||||
<Button Content="New Reinforcement" Command="{Binding AddNewReinforcementMaterialCommand}"/>
|
|
||||||
<Button Content="New Elastic Material" Command="{Binding AddElasticMaterialCommand}"/>
|
|
||||||
<Button Content="Show diagram" Command="{Binding ShowMaterialDiagram}"/>
|
<Button Content="Show diagram" Command="{Binding ShowMaterialDiagram}"/>
|
||||||
<Button Content="Edit color" Command="{Binding EditColorCommand}"/>
|
|
||||||
<Button Content="Edit" Command="{Binding EditCommand}"/>
|
|
||||||
<Button Content="Copy" Command="{Binding CopyHeadMaterialCommand}"/>
|
|
||||||
<Button Content="Delete" Command="{Binding DeleteMaterialCommand}"/>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel x:Name="MatProps" Grid.Column="2">
|
|
||||||
<TextBlock Text="Name"/>
|
|
||||||
<TextBox Text="{Binding SelectedMaterial.Name}"/>
|
|
||||||
<StackPanel x:Name="StpMaterialProperties"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -33,37 +33,5 @@ namespace StructureHelper.Windows.MainWindow.Materials
|
|||||||
this.DataContext = viewModel;
|
this.DataContext = viewModel;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
StpMaterialProperties.Children.Clear();
|
|
||||||
var selectedMaterial = viewModel.SelectedMaterial;
|
|
||||||
if (selectedMaterial == null) { return; }
|
|
||||||
var helperMaterial = selectedMaterial.HelperMaterial;
|
|
||||||
string dataTemplateName = string.Empty;
|
|
||||||
Binding binding = new Binding();
|
|
||||||
if (helperMaterial is IConcreteLibMaterial)
|
|
||||||
{
|
|
||||||
dataTemplateName = "ConcreteLibMaterial";
|
|
||||||
binding.Source = viewModel;
|
|
||||||
}
|
|
||||||
else if (helperMaterial is IReinforcementLibMaterial)
|
|
||||||
{
|
|
||||||
dataTemplateName = "ReinforcementLibMaterial";
|
|
||||||
binding.Source = viewModel;
|
|
||||||
}
|
|
||||||
else if (helperMaterial is IElasticMaterial)
|
|
||||||
{
|
|
||||||
dataTemplateName = "ElasticMaterial";
|
|
||||||
binding.Source = viewModel.SelectedMaterial.HelperMaterial;
|
|
||||||
}
|
|
||||||
if (dataTemplateName != string.Empty)
|
|
||||||
{
|
|
||||||
ContentControl contentControl = new ContentControl();
|
|
||||||
contentControl.SetResourceReference(ContentTemplateProperty, dataTemplateName);
|
|
||||||
contentControl.SetBinding(ContentProperty, binding);
|
|
||||||
StpMaterialProperties.Children.Add(contentControl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
using StructureHelper.Infrastructure.Enums;
|
using StructureHelper.Infrastructure.Enums;
|
||||||
|
using StructureHelper.Models.Materials;
|
||||||
|
using StructureHelper.Services.Settings;
|
||||||
using StructureHelper.Windows.Forces;
|
using StructureHelper.Windows.Forces;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
|
using StructureHelperLogics.Models.Materials;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -15,6 +19,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
|||||||
{
|
{
|
||||||
public class ActionsViewModel : SelectedItemViewModel<IForceAction>
|
public class ActionsViewModel : SelectedItemViewModel<IForceAction>
|
||||||
{
|
{
|
||||||
|
readonly IUpdateStrategy<IAction> updateStrategy = new ActionUpdateStrategy();
|
||||||
ICrossSectionRepository repository;
|
ICrossSectionRepository repository;
|
||||||
|
|
||||||
public override void AddMethod(object parameter)
|
public override void AddMethod(object parameter)
|
||||||
@@ -30,7 +35,8 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
|||||||
{
|
{
|
||||||
NewItem = new ForceCombinationByFactor() { Name = "New Factored Combination" };
|
NewItem = new ForceCombinationByFactor() { Name = "New Factored Combination" };
|
||||||
}
|
}
|
||||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
||||||
|
GlobalRepository.Actions.Create(NewItem);
|
||||||
base.AddMethod(parameter);
|
base.AddMethod(parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +47,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
|||||||
if (dialogResult == DialogResult.Yes)
|
if (dialogResult == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
if (DeleteAction() != true) return;
|
if (DeleteAction() != true) return;
|
||||||
|
GlobalRepository.Materials.Delete(SelectedItem.Id);
|
||||||
base.DeleteMethod(parameter);
|
base.DeleteMethod(parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +56,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
|||||||
|
|
||||||
public override void EditMethod(object parameter)
|
public override void EditMethod(object parameter)
|
||||||
{
|
{
|
||||||
|
var copyObject = GlobalRepository.Actions.GetById(SelectedItem.Id).Clone() as IAction;
|
||||||
System.Windows.Window wnd;
|
System.Windows.Window wnd;
|
||||||
if (SelectedItem is IForceCombinationList)
|
if (SelectedItem is IForceCombinationList)
|
||||||
{
|
{
|
||||||
@@ -62,6 +70,14 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
|||||||
}
|
}
|
||||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"actual object type: {nameof(SelectedItem)}");
|
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"actual object type: {nameof(SelectedItem)}");
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
|
if (wnd.DialogResult == true)
|
||||||
|
{
|
||||||
|
GlobalRepository.Actions.Update(SelectedItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateStrategy.Update(SelectedItem, copyObject);
|
||||||
|
}
|
||||||
base.EditMethod(parameter);
|
base.EditMethod(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelper.Windows.ViewModels.Forces
|
namespace StructureHelper.Windows.ViewModels.Forces
|
||||||
{
|
{
|
||||||
public abstract class ForceActionVMBase : ViewModelBase
|
public abstract class ForceActionVMBase : OkCancelViewModelBase
|
||||||
{
|
{
|
||||||
IForceAction forceAction;
|
IForceAction forceAction;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Infrastructures.Exceptions
|
||||||
|
{
|
||||||
|
public static class ErrorCommonProcessor
|
||||||
|
{
|
||||||
|
public static void ObjectTypeIsUnknown(Type expectedType, Type actualType)
|
||||||
|
{
|
||||||
|
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {expectedType},\n But was: {actualType}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Logic for update object of type <typeparamref name="T"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of object</typeparam>
|
||||||
public interface IUpdateStrategy<T>
|
public interface IUpdateStrategy<T>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Update properties of target object from source object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetObject">Target object</param>
|
||||||
|
/// <param name="sourceObject">Source object</param>
|
||||||
void Update(T targetObject, T sourceObject);
|
void Update(T targetObject, T sourceObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -10,6 +11,8 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
{
|
{
|
||||||
public class DesignForcePair : IDesignForcePair
|
public class DesignForcePair : IDesignForcePair
|
||||||
{
|
{
|
||||||
|
readonly IUpdateStrategy<IAction> updateStrategy = new ActionUpdateStrategy();
|
||||||
|
public Guid Id { get; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public IPoint2D ForcePoint { get; set; }
|
public IPoint2D ForcePoint { get; set; }
|
||||||
public bool SetInGravityCenter { get; set; }
|
public bool SetInGravityCenter { get; set; }
|
||||||
@@ -17,12 +20,16 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
public IForceTuple LongForceTuple { get; set; }
|
public IForceTuple LongForceTuple { get; set; }
|
||||||
public IForceTuple FullForceTuple { get; set; }
|
public IForceTuple FullForceTuple { get; set; }
|
||||||
|
|
||||||
public DesignForcePair()
|
|
||||||
|
public DesignForcePair(Guid id)
|
||||||
{
|
{
|
||||||
|
Id = id;
|
||||||
LongForceTuple = new ForceTuple();
|
LongForceTuple = new ForceTuple();
|
||||||
FullForceTuple = new ForceTuple();
|
FullForceTuple = new ForceTuple();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DesignForcePair() : this(Guid.NewGuid()) {}
|
||||||
|
|
||||||
public IForceCombinationList GetCombinations()
|
public IForceCombinationList GetCombinations()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@@ -30,7 +37,9 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
|
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var newItem = new DesignForcePair();
|
||||||
|
updateStrategy.Update(newItem, this);
|
||||||
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
using System;
|
using System;
|
||||||
@@ -12,6 +13,9 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public class ForceCombinationByFactor : IForceCombinationByFactor
|
public class ForceCombinationByFactor : IForceCombinationByFactor
|
||||||
{
|
{
|
||||||
|
readonly IUpdateStrategy<IAction> updateStrategy = new ActionUpdateStrategy();
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Guid Id { get; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool SetInGravityCenter { get; set; }
|
public bool SetInGravityCenter { get; set; }
|
||||||
@@ -23,8 +27,11 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
public double ULSFactor { get; set; }
|
public double ULSFactor { get; set; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public double LongTermFactor { get; set; }
|
public double LongTermFactor { get; set; }
|
||||||
public ForceCombinationByFactor()
|
|
||||||
|
|
||||||
|
public ForceCombinationByFactor(Guid id)
|
||||||
{
|
{
|
||||||
|
Id = id;
|
||||||
Name = "New Factored Load";
|
Name = "New Factored Load";
|
||||||
SetInGravityCenter = true;
|
SetInGravityCenter = true;
|
||||||
ForcePoint = new Point2D();
|
ForcePoint = new Point2D();
|
||||||
@@ -32,6 +39,7 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
LongTermFactor = 1d;
|
LongTermFactor = 1d;
|
||||||
ULSFactor = 1.2d;
|
ULSFactor = 1.2d;
|
||||||
}
|
}
|
||||||
|
public ForceCombinationByFactor() : this (Guid.NewGuid()) { }
|
||||||
public IForceCombinationList GetCombinations()
|
public IForceCombinationList GetCombinations()
|
||||||
{
|
{
|
||||||
var result = new ForceCombinationList();
|
var result = new ForceCombinationList();
|
||||||
@@ -57,10 +65,7 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var newItem = new ForceCombinationByFactor();
|
var newItem = new ForceCombinationByFactor();
|
||||||
ForceActionService.CopyActionProps(this, newItem);
|
updateStrategy.Update(newItem, this);
|
||||||
newItem.FullSLSForces = FullSLSForces.Clone() as IForceTuple;
|
|
||||||
newItem.LongTermFactor = LongTermFactor;
|
|
||||||
newItem.ULSFactor = ULSFactor;
|
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
using StructureHelperCommon.Models.Shapes;
|
||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Services.Forces;
|
||||||
|
|
||||||
@@ -10,6 +12,9 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public class ForceCombinationList : IForceCombinationList
|
public class ForceCombinationList : IForceCombinationList
|
||||||
{
|
{
|
||||||
|
readonly IUpdateStrategy<IAction> updateStrategy = new ActionUpdateStrategy();
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Guid Id { get; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -18,9 +23,11 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
public IPoint2D ForcePoint { get; set; }
|
public IPoint2D ForcePoint { get; set; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public List<IDesignForceTuple> DesignForces { get; private set; }
|
public List<IDesignForceTuple> DesignForces { get; private set; }
|
||||||
|
|
||||||
public ForceCombinationList()
|
|
||||||
|
public ForceCombinationList(Guid id)
|
||||||
{
|
{
|
||||||
|
Id = id;
|
||||||
SetInGravityCenter = true;
|
SetInGravityCenter = true;
|
||||||
ForcePoint = new Point2D() { X = 0, Y = 0 };
|
ForcePoint = new Point2D() { X = 0, Y = 0 };
|
||||||
DesignForces = new List<IDesignForceTuple>
|
DesignForces = new List<IDesignForceTuple>
|
||||||
@@ -31,17 +38,12 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm)
|
new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public ForceCombinationList() : this (Guid.NewGuid()) { }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var newItem = new ForceCombinationList();
|
var newItem = new ForceCombinationList();
|
||||||
ForceActionService.CopyActionProps(this, newItem);
|
updateStrategy.Update(newItem, this);
|
||||||
newItem.DesignForces.Clear();
|
|
||||||
foreach (var item in DesignForces)
|
|
||||||
{
|
|
||||||
var newForce = item.Clone() as IDesignForceTuple;
|
|
||||||
newItem.DesignForces.Add(newForce);
|
|
||||||
}
|
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Services.Forces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services.Forces;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Forces
|
namespace StructureHelperCommon.Models.Forces
|
||||||
@@ -6,6 +7,7 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public class ForceTuple : IForceTuple
|
public class ForceTuple : IForceTuple
|
||||||
{
|
{
|
||||||
|
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public double Mx { get; set; }
|
public double Mx { get; set; }
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -22,8 +24,9 @@ namespace StructureHelperCommon.Models.Forces
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
ForceTuple forceTuple = new ForceTuple() { Mx = Mx, My = My, Nz = Nz, Qx = Qx, Qy = Qy, Mz = Mz};
|
var newItem = new ForceTuple();
|
||||||
return forceTuple;
|
updateStrategy.Update(newItem, this);
|
||||||
|
return newItem;
|
||||||
}
|
}
|
||||||
public static ForceTuple operator +(ForceTuple first) => first;
|
public static ForceTuple operator +(ForceTuple first) => first;
|
||||||
public static ForceTuple operator +(ForceTuple first, ForceTuple second)
|
public static ForceTuple operator +(ForceTuple first, ForceTuple second)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Models.Forces
|
namespace StructureHelperCommon.Models.Forces
|
||||||
{
|
{
|
||||||
public interface IAction
|
public interface IAction : ISaveable, ICloneable
|
||||||
{
|
{
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,23 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Models.Forces
|
namespace StructureHelperCommon.Models.Forces
|
||||||
{
|
{
|
||||||
public interface IForceAction : IAction, ICloneable
|
/// <summary>
|
||||||
|
/// Action as force load
|
||||||
|
/// </summary>
|
||||||
|
public interface IForceAction : IAction
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// True means force action is put in center of gravity
|
||||||
|
/// </summary>
|
||||||
bool SetInGravityCenter { get; set; }
|
bool SetInGravityCenter { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Point of applying of force load
|
||||||
|
/// </summary>
|
||||||
IPoint2D ForcePoint { get; set; }
|
IPoint2D ForcePoint { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Return combination of forces
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
IForceCombinationList GetCombinations();
|
IForceCombinationList GetCombinations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
public class ActionUpdateStrategy : IUpdateStrategy<IAction>
|
||||||
|
{
|
||||||
|
readonly IUpdateStrategy<IForceAction> forceUpdateStrategy = new ForceActionUpdateStrategy();
|
||||||
|
public void Update(IAction targetObject, IAction sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
|
targetObject.Name = sourceObject.Name;
|
||||||
|
if (targetObject is IForceAction forceAction)
|
||||||
|
{
|
||||||
|
forceUpdateStrategy.Update(forceAction, (IForceAction)sourceObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IAction), sourceObject.GetType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
public class FactorCombinationUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||||
|
{
|
||||||
|
readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||||
|
public void Update(IForceCombinationByFactor targetObject, IForceCombinationByFactor sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
|
tupleUpdateStrategy.Update(targetObject.FullSLSForces, sourceObject.FullSLSForces);
|
||||||
|
targetObject.ULSFactor = sourceObject.ULSFactor;
|
||||||
|
targetObject.LongTermFactor = sourceObject.LongTermFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Shapes.Logics;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
public class ForceActionUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||||
|
{
|
||||||
|
private readonly IUpdateStrategy<IPoint2D> pointStrategy = new PointUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy = new ForcePairUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy = new FactorCombinationUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy = new ForceCombinationListUpdateStrategy();
|
||||||
|
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
|
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||||
|
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||||
|
UpdateChildProperties(targetObject, sourceObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateChildProperties(IForceAction targetObject, IForceAction sourceObject)
|
||||||
|
{
|
||||||
|
if (targetObject is IDesignForcePair pair)
|
||||||
|
{
|
||||||
|
forcePairUpdateStrategy.Update(pair, (IDesignForcePair)sourceObject);
|
||||||
|
}
|
||||||
|
else if (targetObject is IForceCombinationByFactor combination)
|
||||||
|
{
|
||||||
|
factorUpdateStrategy.Update(combination, (IForceCombinationByFactor)sourceObject);
|
||||||
|
}
|
||||||
|
else if (targetObject is IForceCombinationList forceCombinationList)
|
||||||
|
{
|
||||||
|
forceListUpdateStrategy.Update(forceCombinationList, (IForceCombinationList)sourceObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IForceAction), targetObject.GetType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
public class ForceCombinationListUpdateStrategy : IUpdateStrategy<IForceCombinationList>
|
||||||
|
{
|
||||||
|
public void Update(IForceCombinationList targetObject, IForceCombinationList sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
|
var forcesList = new List<IDesignForceTuple>(sourceObject.DesignForces);
|
||||||
|
targetObject.DesignForces.Clear();
|
||||||
|
foreach (var item in forcesList)
|
||||||
|
{
|
||||||
|
targetObject.DesignForces.Add((IDesignForceTuple)item.Clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Shapes;
|
||||||
|
using StructureHelperCommon.Models.Shapes.Logics;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
public class ForcePairUpdateStrategy : IUpdateStrategy<IDesignForcePair>
|
||||||
|
{
|
||||||
|
private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||||
|
public void Update(IDesignForcePair targetObject, IDesignForcePair sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
|
targetObject.LimitState = sourceObject.LimitState;
|
||||||
|
tupleUpdateStrategy.Update(targetObject.LongForceTuple, sourceObject.LongForceTuple);
|
||||||
|
tupleUpdateStrategy.Update(targetObject.FullForceTuple, sourceObject.FullForceTuple);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Forces
|
||||||
|
{
|
||||||
|
internal class ForceTupleUpdateStrategy : IUpdateStrategy<IForceTuple>
|
||||||
|
{
|
||||||
|
public void Update(IForceTuple targetObject, IForceTuple sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(targetObject, ": target object ");
|
||||||
|
CheckObject.IsNull(sourceObject, ": source object ");
|
||||||
|
|
||||||
|
targetObject.Mx = sourceObject.Mx;
|
||||||
|
targetObject.My = sourceObject.My;
|
||||||
|
targetObject.Nz = targetObject.Nz;
|
||||||
|
targetObject.Qx = targetObject.Qx;
|
||||||
|
targetObject.Qy = targetObject.Qy;
|
||||||
|
targetObject.Mz = sourceObject.Mz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Shapes
|
namespace StructureHelperCommon.Models.Shapes
|
||||||
{
|
{
|
||||||
@@ -6,15 +7,15 @@ namespace StructureHelperCommon.Models.Shapes
|
|||||||
/// Interface for point of center of some shape
|
/// Interface for point of center of some shape
|
||||||
/// Интерфейс для точки центра некоторой формы
|
/// Интерфейс для точки центра некоторой формы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPoint2D : ICloneable
|
public interface IPoint2D : ISaveable, ICloneable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Coordinate of center of rectangle by local axis X, m
|
/// Coordinate of center of point by local axis X, m
|
||||||
/// Координата центра вдоль локальной оси X, м
|
/// Координата центра вдоль локальной оси X, м
|
||||||
/// </summary>
|
/// </summary>
|
||||||
double X { get; set; }
|
double X { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Coordinate of center of rectangle by local axis Y, m
|
/// Coordinate of center of point by local axis Y, m
|
||||||
/// Координата центра вдоль локальной оси Y, м
|
/// Координата центра вдоль локальной оси Y, м
|
||||||
/// </summary>
|
/// </summary>
|
||||||
double Y { get; set; }
|
double Y { get; set; }
|
||||||
|
|||||||
@@ -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.Shapes.Logics
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public class PointUpdateStrategy : IUpdateStrategy<IPoint2D>
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Update(IPoint2D targetObject, IPoint2D sourceObject)
|
||||||
|
{
|
||||||
|
targetObject.X = sourceObject.X;
|
||||||
|
targetObject.Y = sourceObject.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,32 @@
|
|||||||
namespace StructureHelperCommon.Models.Shapes
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Shapes.Logics;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Models.Shapes
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public class Point2D : IPoint2D
|
public class Point2D : IPoint2D
|
||||||
{
|
{
|
||||||
|
private readonly IUpdateStrategy<IPoint2D> updateStrategy = new PointUpdateStrategy();
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Guid Id { get; }
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public double Y { get; set; }
|
public double Y { get; set; }
|
||||||
|
|
||||||
|
public Point2D(Guid id)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D() : this(Guid.NewGuid()) { }
|
||||||
|
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var point = new Point2D() { X = X, Y = Y };
|
var newItem = new Point2D();
|
||||||
return point;
|
updateStrategy.Update(newItem, this);
|
||||||
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
StructureHelperCommon/Services/CheckObject.cs
Normal file
38
StructureHelperCommon/Services/CheckObject.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperCommon.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Processor for checking objects
|
||||||
|
/// </summary>
|
||||||
|
public static class CheckObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Compares types of two objects, throws exception if result is not valid
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetObject"></param>
|
||||||
|
/// <param name="sourceObject"></param>
|
||||||
|
/// <exception cref="StructureHelperException"></exception>
|
||||||
|
public static void CompareTypes(object targetObject, object sourceObject)
|
||||||
|
{
|
||||||
|
IsNull(targetObject, "target object");
|
||||||
|
IsNull(targetObject, "source object");
|
||||||
|
if (targetObject.GetType() != sourceObject.GetType())
|
||||||
|
{
|
||||||
|
throw new StructureHelperException
|
||||||
|
($"{ErrorStrings.DataIsInCorrect}: target type is {targetObject.GetType()},\n does not coinside with source type {sourceObject.GetType()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void IsNull(object item, string message = "")
|
||||||
|
{
|
||||||
|
if (item is null) {throw new StructureHelperException (ErrorStrings.ParameterIsNull + message);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,14 +13,6 @@ namespace StructureHelperCommon.Services.Forces
|
|||||||
{
|
{
|
||||||
internal static class ForceActionService
|
internal static class ForceActionService
|
||||||
{
|
{
|
||||||
public static void CopyActionProps(IForceAction source, IForceAction target)
|
|
||||||
{
|
|
||||||
target.Name = source.Name;
|
|
||||||
target.SetInGravityCenter = source.SetInGravityCenter;
|
|
||||||
target.ForcePoint.X = source.ForcePoint.X;
|
|
||||||
target.ForcePoint.Y = source.ForcePoint.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<IDesignForcePair> ConvertCombinationToPairs(IForceCombinationList combinations)
|
public static List<IDesignForcePair> ConvertCombinationToPairs(IForceCombinationList combinations)
|
||||||
{
|
{
|
||||||
var resultList = new List<IDesignForcePair>();
|
var resultList = new List<IDesignForcePair>();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using StructureHelper.Models.Materials;
|
using StructureHelper.Models.Materials;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -11,6 +13,10 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
{
|
{
|
||||||
public class MaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
public class MaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||||
{
|
{
|
||||||
|
private readonly IUpdateStrategy<IElasticMaterial> elasticStrategy = new ElasticUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IFRMaterial> frStrategy = new FRUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IConcreteLibMaterial> concreteStrategy = new ConcreteLibUpdateStrategy();
|
||||||
|
private readonly IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy = new ReinforcementLibUpdateStrategy();
|
||||||
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
||||||
{
|
{
|
||||||
targetObject.Name = sourceObject.Name;
|
targetObject.Name = sourceObject.Name;
|
||||||
@@ -19,70 +25,40 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateHelperMaterial(IHelperMaterial target, IHelperMaterial source)
|
private void UpdateHelperMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||||
{
|
{
|
||||||
Check(target, source);
|
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||||
UpdateMaterial(target, source);
|
if (sourceObject is ILibMaterial)
|
||||||
}
|
|
||||||
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()}");
|
UpdateLibMaterial(targetObject, sourceObject);
|
||||||
}
|
}
|
||||||
}
|
else if (sourceObject is IElasticMaterial)
|
||||||
private static void UpdateMaterial(IHelperMaterial target, IHelperMaterial source)
|
|
||||||
{
|
|
||||||
if (source is ILibMaterial)
|
|
||||||
{
|
{
|
||||||
UpdateLibMaterial(target, source);
|
elasticStrategy.Update(targetObject as IElasticMaterial, sourceObject as IElasticMaterial);
|
||||||
}
|
}
|
||||||
else if (source is IElasticMaterial)
|
else if (sourceObject is IFRMaterial)
|
||||||
{
|
{
|
||||||
UpdateElastic(target, source);
|
frStrategy.Update(targetObject as IFRMaterial, sourceObject as IFRMaterial);
|
||||||
}
|
|
||||||
else if (source is IFRMaterial)
|
|
||||||
{
|
|
||||||
UpdateFR(target, source);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(IHelperMaterial)},\n But was: {source.GetType()}");
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IHelperMaterial), sourceObject.GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void UpdateFR(IHelperMaterial target, IHelperMaterial source)
|
|
||||||
|
private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||||
{
|
{
|
||||||
var targetMaterial = target as IFRMaterial;
|
if (sourceObject is IConcreteLibMaterial)
|
||||||
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;
|
concreteStrategy.Update(targetObject as IConcreteLibMaterial, sourceObject as IConcreteLibMaterial);
|
||||||
var sourceMaterial = source as IConcreteLibMaterial;
|
|
||||||
var logic = new ConcreteLibUpdateStrategy();
|
|
||||||
logic.Update(targetMaterial, sourceMaterial);
|
|
||||||
}
|
}
|
||||||
else if (source is IReinforcementLibMaterial)
|
else if (sourceObject is IReinforcementLibMaterial)
|
||||||
{
|
{
|
||||||
var targetMaterial = target as IReinforcementLibMaterial;
|
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, sourceObject as IReinforcementLibMaterial);
|
||||||
var sourceMaterial = source as IReinforcementLibMaterial;
|
|
||||||
var logic = new ReinforcementLibUpdateStrategy();
|
|
||||||
logic.Update(targetMaterial, sourceMaterial);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(ILibMaterial)},\n But was: {source.GetType()}");
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(ILibMaterial), sourceObject.GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user