/// <summary> /// Creates a <see cref="UpdateInfo"/> object for a <see cref="TSectionContext"/>. /// </summary> /// <typeparam name="TSectionContext">The type of the failure mechanism sections context /// to create the <see cref="UpdateInfo"/> for.</typeparam> /// <typeparam name="TFailureMechanism">The type of the failure mechanism to create /// the <see cref="UpdateInfo"/> for.</typeparam> /// <typeparam name="TSectionResult">The type of the failure mechanism section result /// to create the <see cref="UpdateInfo"/> for.</typeparam> /// <param name="sectionResultUpdateStrategy">The <see cref="IFailureMechanismSectionResultUpdateStrategy{T}"/> /// to use for the created <see cref="UpdateInfo"/>.</param> /// <returns>An <see cref="UpdateInfo"/> object.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="sectionResultUpdateStrategy"/> /// is <c>null</c>.</exception> public static UpdateInfo <TSectionContext> CreateFailureMechanismSectionsUpdateInfo <TSectionContext, TFailureMechanism, TSectionResult>( IFailureMechanismSectionResultUpdateStrategy <TSectionResult> sectionResultUpdateStrategy) where TSectionContext : FailureMechanismSectionsContext where TFailureMechanism : IFailureMechanism <TSectionResult> where TSectionResult : FailureMechanismSectionResult { if (sectionResultUpdateStrategy == null) { throw new ArgumentNullException(nameof(sectionResultUpdateStrategy)); } return(new UpdateInfo <TSectionContext> { Name = Resources.FailureMechanismSections_DisplayName, Category = Resources.Riskeer_Category, Image = Resources.SectionsIcon, FileFilterGenerator = new FileFilterGenerator(RiskeerCommonIOResources.Shape_file_filter_Extension, RiskeerCommonIOResources.Shape_file_filter_Description), IsEnabled = context => context.WrappedData.FailureMechanismSectionSourcePath != null, CurrentPath = context => context.WrappedData.FailureMechanismSectionSourcePath, CreateFileImporter = (context, filePath) => new FailureMechanismSectionsImporter( context.WrappedData, context.AssessmentSection.ReferenceLine, filePath, new FailureMechanismSectionUpdateStrategy <TSectionResult>((TFailureMechanism)context.WrappedData, sectionResultUpdateStrategy), new UpdateMessageProvider()) }); }
/// <summary> /// Creates a new instance of <see cref="FailureMechanismSectionUpdateStrategy{T}"/>. /// </summary> /// <param name="failureMechanism">The <see cref="IFailureMechanism"/> to update the sections for.</param> /// <param name="sectionResultUpdateStrategy">The <see cref="IFailureMechanismSectionResultUpdateStrategy{T}"/> to use when updating /// the section results.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public FailureMechanismSectionUpdateStrategy(IFailureMechanism <T> failureMechanism, IFailureMechanismSectionResultUpdateStrategy <T> sectionResultUpdateStrategy) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } if (sectionResultUpdateStrategy == null) { throw new ArgumentNullException(nameof(sectionResultUpdateStrategy)); } this.failureMechanism = failureMechanism; this.sectionResultUpdateStrategy = sectionResultUpdateStrategy; }