// Copyright (C) Stichting Deltares 2016. All rights preserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights preserved. using System; using System.Drawing; namespace Core.Common.Base.Plugin { /// /// Class that holds information for creating data objects. /// public class DataItemInfo { /// /// Constructs a new . /// public DataItemInfo() { Name = ""; Category = ""; } /// /// Gets or sets the of the data to create. /// public Type ValueType { get; set; } /// /// Gets or sets the name of the data to create. /// public string Name { get; set; } /// /// Gets or sets the category of the data to create. /// public string Category { get; set; } /// /// Gets or sets the image of the data to create. /// public Image Image { get; set; } /// /// Gets or sets a method for determining whether or not the data item information is relevant for the proposed owner. /// public Func AdditionalOwnerCheck { get; set; } /// /// Gets or sets a function for creating the data. /// The object parameter holds the proposed owner of the data to create. /// public Func CreateData { get; set; } } /// /// Class that holds information for creating data objects. /// /// The type of data to create. public class DataItemInfo { /// /// Constructs a new . /// public DataItemInfo() { Name = ""; Category = ""; } /// /// Gets the of the data to create. /// public Type ValueType { get { return typeof(TValue); } } /// /// Gets or sets the name of the data to create. /// public string Name { get; set; } /// /// Gets or sets the category of the data to create. /// public string Category { get; set; } /// /// Gets or sets the image of the data to create. /// public Image Image { get; set; } /// /// Gets or sets a method for determining whether or not the data item information is relevant for the proposed owner. /// public Func AdditionalOwnerCheck { get; set; } /// /// Gets or sets a function for creating the data. /// The object parameter holds the proposed owner of the data to create. /// public Func CreateData { get; set; } /// /// This operator converts a into a . /// /// The to convert. /// The converted . public static implicit operator DataItemInfo(DataItemInfo dataItemInfo) { return new DataItemInfo { ValueType = dataItemInfo.ValueType, Name = dataItemInfo.Name, Category = dataItemInfo.Category, Image = dataItemInfo.Image, AdditionalOwnerCheck = dataItemInfo.AdditionalOwnerCheck != null ? owner => dataItemInfo.AdditionalOwnerCheck(owner) : (Func) null, CreateData = dataItemInfo.CreateData != null ? owner => dataItemInfo.CreateData(owner) : (Func) null }; } } }