using System.Collections.Generic;
using System.Linq;
using Core.Common.Base;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Integration.Data;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
namespace Ringtoets.Integration.Plugin
{
///
/// The application plugin for Ringtoets.
///
public class RingtoetsApplicationPlugin : ApplicationPlugin
{
public override IEnumerable GetDataItemInfos()
{
yield return new DataItemInfo
{
Name = RingtoetsFormsResources.DikeAssessmentSection_DisplayName,
Category = RingtoetsCommonFormsResources.Ringtoets_Category,
Image = RingtoetsFormsResources.AssessmentSectionFolderIcon,
CreateData = owner =>
{
var project = (Project)owner;
var dikeAssessmentSection = new DikeAssessmentSection();
dikeAssessmentSection.Name = GetUniqueForAssessmentSectionName(project, dikeAssessmentSection.Name);
return dikeAssessmentSection;
}
};
yield return new DataItemInfo
{
Name = RingtoetsFormsResources.DuneAssessmentSection_DisplayName,
Category = RingtoetsCommonFormsResources.Ringtoets_Category,
Image = RingtoetsFormsResources.AssessmentSectionFolderIcon,
CreateData = owner =>
{
var project = (Project)owner;
var duneAssessmentSection = new DuneAssessmentSection();
duneAssessmentSection.Name = GetUniqueForAssessmentSectionName(project, duneAssessmentSection.Name);
return duneAssessmentSection;
}
};
}
private static string GetUniqueForAssessmentSectionName(Project project, string baseName)
{
return NamingHelper.GetUniqueName(project.Items.OfType(), baseName, a => a.Name);
}
}
}