FixActionDeleting
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,6 +9,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public interface IRepositoryOperationsLogic
|
||||
{
|
||||
IRepositoryOperation<ICrossSectionRepository, IForceAction> Actions { get; }
|
||||
IRepositoryOperation<ICrossSectionRepository, INdmPrimitive> Primitives { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class RepositoryActionOperations : IRepositoryOperation<ICrossSectionRepository, IForceAction>
|
||||
{
|
||||
private ICrossSectionRepository repository;
|
||||
|
||||
public RepositoryActionOperations(ICrossSectionRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public void Remove(IForceAction entity)
|
||||
{
|
||||
foreach (var calc in repository.Calculators)
|
||||
{
|
||||
if (calc is IForceCalculator forceCalculator)
|
||||
{
|
||||
forceCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ICrackCalculator crackCalculator)
|
||||
{
|
||||
crackCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ILimitCurvesCalculator)
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
else if (calc is IValueDiagramCalculator diagramCalculator)
|
||||
{
|
||||
diagramCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else if (calc is ICurvatureCalculator curvatureCalculator)
|
||||
{
|
||||
curvatureCalculator.InputData.ForceActions.Remove(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
|
||||
}
|
||||
}
|
||||
repository.ForceActions.Remove(entity);
|
||||
}
|
||||
|
||||
public void Remove(IEnumerable<IForceAction> entities)
|
||||
{
|
||||
foreach (var item in entities)
|
||||
{
|
||||
Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using NLog.LayoutRenderers;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
@@ -7,6 +10,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
private ICrossSectionRepository repository;
|
||||
private RepositoryPrimitiveOperation primitiveLogic;
|
||||
private IRepositoryOperation<ICrossSectionRepository, IForceAction> actionLogic;
|
||||
|
||||
public RepositoryOperationsLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
@@ -14,5 +18,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
}
|
||||
|
||||
public IRepositoryOperation<ICrossSectionRepository, INdmPrimitive> Primitives => primitiveLogic ??= new RepositoryPrimitiveOperation(repository);
|
||||
|
||||
public IRepositoryOperation<ICrossSectionRepository, IForceAction> Actions => actionLogic ??= new RepositoryActionOperations(repository);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user