using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace Bwp.ABCClient2.Core { public class MerchantScope:IDisposable { volatile static object mLocker = new object(); bool enterScope = false; public MerchantScope(string merchantID,string trustPayConnectMethod,string trustPayServerName,int trustPayServerPort,string trustPayTrxURL) { if (!Monitor.TryEnter(mLocker)) { throw new Exception("另外一个商户的业务正在进行"); } else { enterScope = true; ABCClientConfig.mMerchantID = merchantID; ABCClientConfig.mTrustPayConnectMethod = trustPayConnectMethod; ABCClientConfig.mTrustPayServerName = trustPayServerName; ABCClientConfig.mTrustPayTrxURL = trustPayTrxURL; ABCClientConfig.mTrustPayServerPort = trustPayServerPort; } } public void Dispose() { if (enterScope) { Monitor.Exit(mLocker); } } } }