csharp/0xC0000054/pdn-gmic/src/OutputImageState.cs

OutputImageState.cs
/*
*  This file is part of pdn-gmic, a Paint.NET Effect that
*  that provides integration with G'MIC-Qt.
*
*  Copyright (C) 2018, 2019, 2020, 2021 Nicholas Hayes
*
*  pdn-gmic is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  pdn-gmic 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 General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see .
*
*/

using PaintDotNet;
using System;
using System.Collections.Generic;

namespace GmicEffectPlugin
{
    internal sealed clast OutputImageState : IDisposable
    {
        public OutputImageState(Exception error, IReadOnlyList outputImages)
        {
            Error = error;
            OutputImages = outputImages;
        }

        public Exception Error { get; }

        public IReadOnlyList OutputImages { get; private set; }

        public void Dispose()
        {
            if (OutputImages != null)
            {
                IReadOnlyList output = OutputImages;
                OutputImages = null;

                for (int i = 0; i < output.Count; i++)
                {
                    output[i]?.Dispose();
                }
            }
        }
    }
}