// Copyright (C) Stichting Deltares 2016. All rights reserved. // // 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 reserved. using System; using System.Drawing; using Core.Common.Base.IO; namespace Core.Common.Gui.Plugin { /// /// Information for creating an importer for updating a particular data object. /// public class UpdateInfo { /// /// Gets or sets the data type associated with this import info. /// public Type DataType { get; set; } /// /// Gets or sets the method used to create a used to update data. /// Function arguments: /// /// The data to import. /// The file to import data from. /// out - The created importer. /// /// public Func CreateFileImporter { get; set; } /// /// Gets or sets the method used to determine whether or not the import routine should be enabled. Function arguments: /// /// The data to import. /// out - true if the import should be enabled, false otherwise. /// /// public Func IsEnabled { get; set; } /// /// Gets or sets the method used to verify whether changes that are induced by the importer /// are allowed. /// public Func VerifyUpdates { get; set; } /// /// Gets or sets the current path from which the current data was imported. /// public Func CurrentPath { get; set; } /// /// Gets or sets the name of the import information. /// public string Name { get; set; } /// /// Gets or sets the category of the import information. /// public string Category { get; set; } /// /// Gets or sets the image of the import information. /// public Image Image { get; set; } /// /// Gets or sets the file filter of the import information. /// public FileFilterGenerator FileFilter { get; set; } } /// /// Information for creating an importer for updating a particular data object. /// /// The data type associated with this import info. public class UpdateInfo { /// /// Gets the data type associated with this import info. /// public Type DataType { get { return typeof(TData); } } /// /// Gets or sets the method used to create a used to update data. /// Function arguments: /// /// The data to import. /// The path to the file to import from. /// out - The created importer. /// /// public Func CreateFileImporter { get; set; } /// /// Gets or sets the method used to determine whether or not the import routine should be enabled. Function arguments: /// /// The data to import. /// out - true if the import should be enabled, false otherwise. /// /// public Func IsEnabled { get; set; } /// /// Gets or sets the method used to verify whether changes that are induced by the importer /// are allowed. /// public Func VerifyUpdates { get; set; } /// /// Gets or sets the current path from which the current data was imported. /// public Func CurrentPath { get; set; } /// /// Gets or sets the name of the import information. /// public string Name { get; set; } /// /// Gets or sets the category of the import information. /// public string Category { get; set; } /// /// Gets or sets the image of the import information. /// public Image Image { get; set; } /// /// Gets or sets the file filter of the import information. /// public FileFilterGenerator FileFilter { get; set; } /// /// Performs an implicit conversion from to . /// /// The import information to convert. /// The result of the conversion. public static implicit operator UpdateInfo(UpdateInfo importInfo) { return new UpdateInfo { DataType = importInfo.DataType, CreateFileImporter = (data, path) => importInfo.CreateFileImporter?.Invoke((TData) data, path), IsEnabled = data => importInfo.IsEnabled == null || importInfo.IsEnabled((TData) data), VerifyUpdates = data => importInfo.VerifyUpdates == null || importInfo.VerifyUpdates((TData) data), CurrentPath = data => importInfo.CurrentPath?.Invoke((TData) data), Name = importInfo.Name, Category = importInfo.Category, Image = importInfo.Image, FileFilter = importInfo.FileFilter }; } } }