/// <summary> /// Registers a loader/saver for a specified image file type. /// </summary> /// <param name="type">The file type (use integer and explicit casting to <see cref="ImageFileType"/> to register other fileformat.</param> /// <param name="loader">The loader delegate (can be null).</param> /// <param name="saver">The saver delegate (can be null).</param> /// <exception cref="System.ArgumentException"></exception> public static void Register(ImageFileType type, ImageLoadDelegate loader, ImageSaveDelegate saver) { // If reference equals, then it is null if (ReferenceEquals(loader, saver)) throw new ArgumentNullException("Can set both loader and saver to null", "loader/saver"); var newDelegate = new LoadSaveDelegate(type, loader, saver); for (int i = 0; i < loadSaveDelegates.Count; i++) { var loadSaveDelegate = loadSaveDelegates[i]; if (loadSaveDelegate.FileType == type) { loadSaveDelegates[i] = newDelegate; return; } } loadSaveDelegates.Add(newDelegate); }
public LoadSaveDelegate(ImageFileType fileType, ImageLoadDelegate load, ImageSaveDelegate save) { FileType = fileType; Load = load; Save = save; }