using System; using System.Drawing; namespace Core.Common.Base { /// /// Information for creating data objects /// public class DataItemInfo { /// /// The type of data to create /// public Type ValueType { get; set; } /// /// The name of the data to create /// public string Name { get; set; } /// /// The category of the data to create /// public string Category { get; set; } /// /// The image of the data to create /// public Image Image { get; set; } /// /// Method for determining whether or not the data item information is relevant for the proposed owner /// public Func AdditionalOwnerCheck { get; set; } /// /// Function for creating the data /// /// /// The object parameter holds the proposed owner of the data to create /// public Func CreateData { get; set; } /// /// Action for adding example data to the created data /// public Action AddExampleData { get; set; } } /// /// Information for creating data objects /// /// The type of data to create public class DataItemInfo { /// /// The type of data to create /// public Type ValueType { get { return typeof(TValue); } } /// /// The name of the data to create /// public string Name { get; set; } /// /// The category of the data to create /// public string Category { get; set; } /// /// The image of the data to create /// public Image Image { get; set; } /// /// Method for determining whether or not the data item information is relevant for the proposed owner /// public Func AdditionalOwnerCheck { get; set; } /// /// Function for creating the data /// /// /// The object parameter holds the proposed owner of the data to create /// public Func CreateData { get; set; } /// /// Action for adding example data to the created data /// public Action AddExampleData { get; set; } 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, AddExampleData = dataItemInfo.AddExampleData != null ? d => dataItemInfo.AddExampleData((TValue) d) : (Action) null }; } } }