using System; using System.Drawing; namespace Core.Common.Base.Plugin { /// /// Class that holds information for creating data objects. /// public class DataItemInfo { /// /// 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 set a method for determining whether or not the data item information is relevant for the proposed owner. /// public Func AdditionalOwnerCheck { get; set; } /// /// Gets or set 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 { /// /// 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 set a method for determining whether or not the data item information is relevant for the proposed owner. /// public Func AdditionalOwnerCheck { get; set; } /// /// Gets or set 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 }; } } }