// Updates IdentityId to new value and fires IdentityChangedEvent
        private void UpdateIdentity(string newIdentityId)
        {
            // No-op if new IdentityId is same as old
            if (string.Equals(identityId, newIdentityId, StringComparison.Ordinal))
            {
                return;
            }

            //save the new identity id and destroy the credentials associated with the old id.
            CacheIdentityId(newIdentityId);
            ClearCredentials();

            // Swap in new identity
            string oldIdentityId = identityId;

            identityId = newIdentityId;
            // Fire the event
            var handler = mIdentityChangedEvent;

            if (handler != null)
            {
                var args = new IdentityChangedArgs(oldIdentityId, newIdentityId);
                handler(this, args);
            }
        }
        // Updates IdentityId to new value and fires IdentityChangedEvent
        private void UpdateIdentity(string newIdentityId, bool updateCache)
        {
            // No-op if new IdentityId is same as old
            if (string.Equals(identityId, newIdentityId, StringComparison.Ordinal))
            {
                return;
            }

            if (updateCache)
            {
                this.CacheIdentityId(newIdentityId);
            }

            // Swap in new identity
            string oldIdentityId = identityId;

            identityId = newIdentityId;

            // Fire the event
            var handler = IdentityChangedEvent;

            if (handler != null)
            {
                var args = new IdentityChangedArgs(oldIdentityId, newIdentityId);
                handler(this, args);
            }
        }
 private void UpdateIdentity(string newIdentityId)
 {
     if (!string.Equals(identityId, newIdentityId, StringComparison.Ordinal))
     {
         CacheIdentityId(newIdentityId);
         ClearCredentials();
         string oldIdentityId = identityId;
         identityId = newIdentityId;
         EventHandler <IdentityChangedArgs> eventHandler = mIdentityChangedEvent;
         if (eventHandler != null)
         {
             IdentityChangedArgs e = new IdentityChangedArgs(oldIdentityId, newIdentityId);
             eventHandler(this, e);
         }
     }
 }
        // Updates IdentityId to new value and fires IdentityChangedEvent
        public void UpdateIdentity(string newIdentityId)
        {
            // No-op if new IdentityId is same as old
            if (_identityId == newIdentityId)
            {
                return;
            }

            // Swap in new identity
            string oldIdentityId = _identityId;

            _identityId = newIdentityId;

            // Fire the event
            var handler = IdentityChangedEvent;

            if (handler != null)
            {
                var args = new IdentityChangedArgs(oldIdentityId, newIdentityId);
                handler(this, args);
            }
        }