﻿using System;

namespace Unity.Muninn.Model
{
    public enum SliceOperation
    {
        SliceIncreaseIndex,
        SliceSetIndex,
        SlicePurgeIndex,
        SlicePurgeUpToIndex,
    }

    public static class SliceOperationConverter
    {
        public static SliceOperation ToModel(this Unity.Muninn.Message.SliceOperation sliceOperation)
        {
            switch (sliceOperation)
            {
                case Message.SliceOperation.SliceIncreaseIndex:
                    return SliceOperation.SliceIncreaseIndex;
                case Message.SliceOperation.SlicePurgeIndex:
                    return SliceOperation.SlicePurgeIndex;
                case Message.SliceOperation.SliceSetIndex:
                    return SliceOperation.SliceSetIndex;
                case Message.SliceOperation.SlicePurgeUpToIndex:
                    return SliceOperation.SlicePurgeIndex;
                default:
                    throw new ArgumentOutOfRangeException(nameof(sliceOperation), sliceOperation, null);
            }
        }

        public static Message.SliceOperation ToMessage(this SliceOperation sliceOperation)
        {
            switch (sliceOperation)
            {
                case SliceOperation.SliceIncreaseIndex:
                    return Message.SliceOperation.SliceIncreaseIndex;
                case SliceOperation.SlicePurgeIndex:
                    return Message.SliceOperation.SlicePurgeIndex;
                case SliceOperation.SliceSetIndex:
                    return Message.SliceOperation.SliceSetIndex;
                case SliceOperation.SlicePurgeUpToIndex:
                    return Message.SliceOperation.SlicePurgeIndex;
                default:
                    throw new ArgumentOutOfRangeException(nameof(sliceOperation), sliceOperation, null);
            }
        }
    }
}