/// <summary>
        /// 執行API
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="carrierTitleModel"></param>
        /// <returns></returns>
        private string ExcuteApi <T>(T carrierTitleModel) where T :
        class, new()
        {
            var api = _invoiceApiFactroy.GetProxyInstace(carrierTitleModel);

            return(api.ExcuteApi(carrierTitleModel));
        }
Пример #2
0
        static void Main(string[] args)
        {
            //設定使用哪個抓取Setting類別
            var setting = new AppsettingConfig();

            //建立工廠 將配置檔傳入建構子中
            InvoiceApiFactroy factory = new InvoiceApiFactroy(setting);

            //建立查詢參數
            //下面範例查詢 發票民國106年7.8月中獎發票
            QryWinningListModel model = new QryWinningListModel()
            {
                invTerm = "10608"
            };


            //在工廠中藉由傳入參數 取得Api產品
            var api = factory.GetProxyInstace(model);

            //api回傳結果
            var result = api.ExcuteApi(model);

            Console.WriteLine(result);

            Console.ReadKey();
        }
Пример #3
0
            public void Compare()
            {
                InvoiceApiFactroy factory = new InvoiceApiFactroy(_config);

                var model = Activator.CreateInstance(typeof(T)) as T;

                var reuslt = factory.GetProxyInstace(model);

                Assert.AreEqual(ApiType, reuslt.GetType());
                Assert.AreEqual(reuslt.ConfigSetting, _config);
            }
Пример #4
0
        static void Main(string[] args)
        {
            //Register Assembly you want to inject.
            ApiTypeProvider.Instance.RegistertAssembly(Assembly.GetExecutingAssembly());

            string result = string.Empty;

            #region 使用工廠模式
            //建立查詢參數
            //下面範例查詢 發票民國106年7.8月中獎發票
            QryWinningListModel model = new QryWinningListModel()
            {
                invTerm = "10610"
            };

            //建立工廠 將配置檔傳入建構子中
            InvoiceApiFactroy factory = new InvoiceApiFactroy();

            //在工廠中藉由傳入參數 取得Api產品
            var api = factory.GetProxyInstace(model);

            //api回傳結果
            result = api.ExcuteApi(model);
            Console.WriteLine(result);
            #endregion

            #region 使用 InvoiceApiContext

            DonateQueryModel donateModel = new DonateQueryModel()
            {
                qKey = "伊甸"
            };
            InvoiceApiContext apiContext = new InvoiceApiContext();
            result = apiContext.ExcuteApi(donateModel);
            #endregion

            Console.WriteLine(result);
            Console.ReadKey();
        }