// <auto-generated>
// Auto-generated by StoneAPI, do not modify.
// </auto-generated>

namespace Dropbox.Api.TeamLog
{
    using sys = System;
    using col = System.Collections.Generic;
    using re = System.Text.RegularExpressions;

    using enc = Dropbox.Api.Stone;

    /// <summary>
    /// <para>File's logged information.</para>
    /// </summary>
    /// <seealso cref="Global::Dropbox.Api.TeamLog.FileOrFolderLogInfo" />
    public class FileLogInfo : FileOrFolderLogInfo
    {
        #pragma warning disable 108

        /// <summary>
        /// <para>The encoder instance.</para>
        /// </summary>
        internal static enc.StructEncoder<FileLogInfo> Encoder = new FileLogInfoEncoder();

        /// <summary>
        /// <para>The decoder instance.</para>
        /// </summary>
        internal static enc.StructDecoder<FileLogInfo> Decoder = new FileLogInfoDecoder();

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="FileLogInfo" /> class.</para>
        /// </summary>
        /// <param name="path">Path relative to event context.</param>
        /// <param name="displayName">Display name.</param>
        /// <param name="fileId">Unique ID.</param>
        /// <param name="fileSize">File or folder size in bytes.</param>
        public FileLogInfo(PathLogInfo path,
                           string displayName = null,
                           string fileId = null,
                           ulong? fileSize = null)
            : base(path, displayName, fileId, fileSize)
        {
        }

        /// <summary>
        /// <para>Initializes a new instance of the <see cref="FileLogInfo" /> class.</para>
        /// </summary>
        /// <remarks>This is to construct an instance of the object when
        /// deserializing.</remarks>
        [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
        public FileLogInfo()
        {
        }

        #region Encoder class

        /// <summary>
        /// <para>Encoder for  <see cref="FileLogInfo" />.</para>
        /// </summary>
        private class FileLogInfoEncoder : enc.StructEncoder<FileLogInfo>
        {
            /// <summary>
            /// <para>Encode fields of given value.</para>
            /// </summary>
            /// <param name="value">The value.</param>
            /// <param name="writer">The writer.</param>
            public override void EncodeFields(FileLogInfo value, enc.IJsonWriter writer)
            {
                WriteProperty("path", value.Path, writer, global::Dropbox.Api.TeamLog.PathLogInfo.Encoder);
                if (value.DisplayName != null)
                {
                    WriteProperty("display_name", value.DisplayName, writer, enc.StringEncoder.Instance);
                }
                if (value.FileId != null)
                {
                    WriteProperty("file_id", value.FileId, writer, enc.StringEncoder.Instance);
                }
                if (value.FileSize != null)
                {
                    WriteProperty("file_size", value.FileSize.Value, writer, enc.UInt64Encoder.Instance);
                }
            }
        }

        #endregion


        #region Decoder class

        /// <summary>
        /// <para>Decoder for  <see cref="FileLogInfo" />.</para>
        /// </summary>
        private class FileLogInfoDecoder : enc.StructDecoder<FileLogInfo>
        {
            /// <summary>
            /// <para>Create a new instance of type <see cref="FileLogInfo" />.</para>
            /// </summary>
            /// <returns>The struct instance.</returns>
            protected override FileLogInfo Create()
            {
                return new FileLogInfo();
            }

            /// <summary>
            /// <para>Set given field.</para>
            /// </summary>
            /// <param name="value">The field value.</param>
            /// <param name="fieldName">The field name.</param>
            /// <param name="reader">The json reader.</param>
            protected override void SetField(FileLogInfo value, string fieldName, enc.IJsonReader reader)
            {
                switch (fieldName)
                {
                    case "path":
                        value.Path = global::Dropbox.Api.TeamLog.PathLogInfo.Decoder.Decode(reader);
                        break;
                    case "display_name":
                        value.DisplayName = enc.StringDecoder.Instance.Decode(reader);
                        break;
                    case "file_id":
                        value.FileId = enc.StringDecoder.Instance.Decode(reader);
                        break;
                    case "file_size":
                        value.FileSize = enc.UInt64Decoder.Instance.Decode(reader);
                        break;
                    default:
                        reader.Skip();
                        break;
                }
            }
        }

        #endregion
    }
}
