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

namespace PTMedicalInsurance.Helper
{
    class InvokeCenterFactory
    {
        private static IInvokeCenter __invoker = null;
        private static string mode = ""; // dll,ocx,rest

        /// <summary>
        /// 通过配置加载调用模式(默认为dll)
        /// </summary>
        private static void init()
        {
            mode = "dll";
        }

        /// <summary>
        /// 创建调用模式
        /// </summary>
        /// <returns></returns>
        public static IInvokeCenter create()
        {
            if (string.IsNullOrEmpty(mode)) {
                init();
            }

            if (__invoker != null) return __invoker;

            switch (mode)
            {
                case "dll":
                    __invoker = new InvokeDllCenter();
                    break;
                case "ocx":
                    __invoker = new InvokeDllCenter();
                    break;
                case "rest":
                default:
                    __invoker = new InvokeRestCenter();
                    break;
            }
            return __invoker;
            
        }


    }
}
