using Volpe.Cafe.MarketData.BaselineInfo;

namespace Volpe.Cafe.MarketData.Parsers
{
    /// <summary>
    /// Provides helper methods for parsing component info.
    /// </summary>
    public static class ComponentParser
    {
        /// <summary>
        /// Returns an automatically generated family name for the specified <see cref="BaselineComponent"/>.
        /// </summary>
        public static string AutoGenerateFamilyName(this BaselineComponent component)
        {
            return $"{GetAutoGenBase(component)}:Family";
        }

        /// <summary>
        /// Returns an automatically generated component name for the specified <see cref="BaselineComponent"/>.
        /// </summary>
        /// <remarks>
        /// <b>NOTE</b>:
        /// For auto-generated component names, this method assumes that sub-classes derived from
        /// <see cref="BaselineComponent"/> override the <see cref="object.ToString"/> method to provide relevant
        /// information for a specific component type.
        /// </remarks>
        public static string AutoGenerateComponentName(this BaselineComponent component)
        {
            return $"{GetAutoGenBase(component)}:{component}";
        }

        private static string GetAutoGenBase(this BaselineComponent component)
        {
            return $"__autogen__:{component.ManufacturerName}:{component.Code}";
        }

    }
}
