using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyDevCore.Configuration
{
    /// <summary>
    /// 
    /// </summary>
    [Flags]
    public enum EasyConfigPropertyOptions
    {
        /// <summary>
        /// 
        /// </summary>
        None = 0,
        /// <summary>
        /// It will be save in Binary Serialization
        /// </summary>
        Serialization = 1,
        /// <summary>
        /// It has been encrypted
        /// </summary>
        Encrypted = 2,
        /// <summary>
        /// Internal property / Not save in file
        /// </summary>
        Internal = 4
    }

    /// <summary>
    /// 
    /// </summary>
    /// <seealso cref="System.Attribute" />
    public class EasyConfigPropertyAttribute: Attribute
    {
        /// <summary>
        /// Gets or sets the default value.
        /// </summary>
        /// <value>The default value.</value>
        public object DefaultValue { get; set; }

        /// <summary>
        /// Gets or sets the min value.
        /// </summary>
        /// <value>
        /// The min value.
        /// </value>
        public object MinValue { get; set; }

        /// <summary>
        /// Gets or sets the max value.
        /// </summary>
        /// <value>
        /// The max value.
        /// </value>
        public object MaxValue { get; set; }
        /// <summary>
        /// Gets or sets the tag.
        /// </summary>
        /// <value>
        /// The tag.
        /// </value>
        public string Tag { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is encrypted.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is encrypted; otherwise, <c>false</c>.
        /// </value>
        public bool IsEncrypted
        {
            get
            {
                return ((Options & EasyConfigPropertyOptions.Encrypted) != EasyConfigPropertyOptions.None);
            }
            set
            {
                if (value)
                {
                    Options |= EasyConfigPropertyOptions.Encrypted;
                }
                else
                {
                    Options &= ~EasyConfigPropertyOptions.Encrypted;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is internal.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is internal; otherwise, <c>false</c>.
        /// </value>
        public bool IsInternal
        {
            get
            {
                return ((Options & EasyConfigPropertyOptions.Internal) != EasyConfigPropertyOptions.None);
            }
            set
            {
                if (value)
                {
                    Options |= EasyConfigPropertyOptions.Internal;
                }
                else
                {
                    Options &= ~EasyConfigPropertyOptions.Internal;
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is serialization.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is serialization; otherwise, <c>false</c>.
        /// </value>
        public bool IsSerialization
        {
            get
            {
                return ((Options & EasyConfigPropertyOptions.Serialization) != EasyConfigPropertyOptions.None);
            }
            set
            {
                if (value)
                {
                    Options |= EasyConfigPropertyOptions.Serialization;
                }
                else
                {
                    Options &= ~EasyConfigPropertyOptions.Serialization;
                }
            }
        }

        /// <summary>
        /// Gets or sets the alias.
        /// </summary>
        /// <value>
        /// The alias.
        /// </value>
        public string Alias { get; set; }

        /// <summary>
        /// Gets or sets the options.
        /// </summary>
        /// <value>The options.</value>
        public EasyConfigPropertyOptions Options { get; set; }
    }
}
