// WS-POS version 1.3 参照実装
// 
// 実装 version 0.6 

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Configuration;

namespace WSPOSInitiative.Common
{
    /// <summary>
    /// ログのインスタンスを生成するファクトリ
    /// The factory which generates the instance of a log 
    /// </summary>
    class LogFactory
    {
        /// <summary>
        /// ログのインスタンスを生成
        /// Creates an instance of the log
        /// </summary>
        /// <returns>ログ | log</returns>
        internal static ILog CreateLogInstance()
        {
            if (StringArrayContainsHelper.Contains(ConfigurationManager.AppSettings.AllKeys, "CommonBehavior_LogImpl") == false)
            {
                return new LogDebugPrintImpl();
            }

            string[] logLoadString = ConfigurationManager.AppSettings["CommonBehavior_LogImpl"].Split(',');

            Assembly logAssembly = Assembly.LoadFrom(logLoadString[0]);

            Type logType = logAssembly.GetType(logLoadString[1]);

            ILog log = (ILog)Activator.CreateInstance(logType);

            return log;
        }
    }
}
