Esempio n. 1
0
        protected VcodeProvider(VcodePlatform platform, string user, string pwd, string softId, string softKey, object tag)
        {
            if (platform == null)
            {
                throw new ArgumentNullException("platform");
            }

            this.platform = platform;
            this.user     = user;
            this.pwd      = pwd;
            this.softId   = softId;
            this.softKey  = softKey;
            this.tag      = tag;
        }
Esempio n. 2
0
        /// <summary>
        /// 更改已注册的打码平台的打码账户信息
        /// </summary>
        /// <param name="platform"></param>
        /// <param name="user"></param>
        /// <param name="pwd"></param>
        /// <param name="softId"></param>
        /// <param name="softKey"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public bool InitializePlatform(VcodePlatform platform, string user, string pwd, string softId = null, string softKey = null, object tag = null, bool setAsCurrentPlatform = false)
        {
            if (platform == null)
            {
                throw new ArgumentNullException("platform");
            }

            if (!vcodeDict.ContainsKey(platform))
            {
                throw new KeyNotFoundException("the platform is not found in SupportedPlatforms, you should register it first.");
            }

            var vcode = vcodeDict[platform];
            var force = vcode.Username != user || vcode.Password != pwd ||
                        vcode.SoftId != softId || vcode.SoftKey != softKey || vcode.Tag != tag;

            if (!string.IsNullOrEmpty(user))
            {
                vcode.Username = user;
            }
            if (!string.IsNullOrEmpty(pwd))
            {
                vcode.Password = pwd;
            }
            if (!string.IsNullOrEmpty(softId))
            {
                vcode.SoftId = softId;
            }
            if (!string.IsNullOrEmpty(softKey))
            {
                vcode.SoftKey = softKey;
            }
            if (tag != null)
            {
                vcode.Tag = tag;
            }
            var result = vcode.Initialize(force);

            if (result && setAsCurrentPlatform)
            {
                currentProvider = vcode;
            }
            return(result);
        }
Esempio n. 3
0
 public VcodeManager()
 {
     AddDefaultPlatforms();
     CurrentPlatform = VcodePlatform.Manual;
 }