using System;

namespace Toolbox.Docking.Api.Objects
{
    /// <summary>
    /// Basic class for describing a Toolbox object. This is used
    /// throughout Toolbox as an object identifiers.
    /// </summary>
    [Serializable]
    public sealed class TbObjectId
    {
        /// <summary>
        /// Basic object constructor.
        /// </summary>
        /// <param name="caption">The name of the Toolbox object.</param>
        /// <param name="guid">The persistent identifier of the object.</param>
        /// <param name="version">Version of the object</param>
        public TbObjectId(string caption, Guid guid, Version version)
        {
            Caption = caption;
            Guid = guid;
            Version = version;
        }

        /// <summary>
        /// The name of the Toolbox object.
        /// </summary>
        public string Caption { get; }

        /// <summary>
        /// The identifier of the object. This identifier should persist
        /// through different Toolbox runs.
        /// </summary>
        public Guid Guid { get; }

        /// <summary>
        /// Toolbox object version.
        /// </summary>
        public Version Version { get; }

        /// <summary>
        /// Returns basic information for the object.
        /// </summary>
        /// <returns>
        /// UI friendly string representation of the object.
        /// </returns>
        public override string ToString()
        {
            return $"{Caption} (version {Version}) [{Guid}]";
        }
    }
}