Пример #1
0
        /*
         *  This method simply wraps the Activate and RenewToken methods
         *  (below) into one convenient form.   Activate is called if needed,
         *  and then RenewToken is called, and the renewed Token returned.
         */
        public PosToken ActivateIfNeededAndRenewToken()
        {
            PosToken    token       = null;
            Credentials credentials = _repo.GetIfPresent(_config.CredentialsKey);

            try
            {
                while (true)
                {
                    if (credentials == null)
                    {
                        credentials = Activate();
                    }
                    if (credentials != null)
                    {
                        token = RenewToken(credentials);
                        if (token != null)
                        {
                            _repo.SaveCredentials(_config.CredentialsKey, credentials);
                            break;
                        }
                        // incorrect credentials, need to activate
                        credentials = null;
                    }
                }
                return(token);
            }
            catch (ApplicationException)
            {
                throw;
            }
        }
Пример #2
0
        protected override IToken makeToken(int t)
        {
            PosToken tok = new PosToken(t);

            tok.setColumn(tokenStartCol);
            tok.setLine(tokenStartLine);
            tok.setPosition(tokenStartCharPos);
            return(tok);
        }