internal void UpdateForVersion(ApiVersion version, AuthorizationRules existingAuthorizationRules = null)
        {
            if (version < ApiVersion.Three)
            {
                // API V2 does not understand SharedAccessAuthorizationRule, so we explicitly
                // remove it.
                foreach (var rule in this.nameToSharedAccessAuthorizationRuleMap.Values)
                {
                    this.innerCollection.Remove(rule);
                }

                this.nameToSharedAccessAuthorizationRuleMap.Clear();

                if (existingAuthorizationRules != null)
                {
                    // Given an existing rule set (we get existing ruleset in update scenarios),
                    // for version 2 and below we need to merge back the SharedAccess rule that
                    // is not understood by these version.
                    foreach (SharedAccessAuthorizationRule rule in existingAuthorizationRules.nameToSharedAccessAuthorizationRuleMap.Values)
                    {
                        this.Add(rule);
                    }
                }
            }
        }
        /// <summary>
        /// Determines whether the specified <see cref="T:Microsoft.Azure.NotificationHubs.Messaging.AuthorizationRules"/> has equal runtime behavior as this current object.
        /// </summary>
        ///
        /// <returns>
        /// true if the they are the equal runtime behavior; otherwise, false.
        /// </returns>
        /// <param name="comparand">The <see cref="T:Microsoft.Azure.NotificationHubs.Messaging.AuthorizationRules"/> to compare to the current object.</param>
        public bool HasEqualRuntimeBehavior(AuthorizationRules comparand)
        {
            if (comparand == null)
            {
                return(false);
            }

            AuthorizationRuleEqualityComparer equalityComparer = new AuthorizationRuleEqualityComparer();
            HashSet <AuthorizationRule>       thisRules        = new HashSet <AuthorizationRule>(this.innerCollection, equalityComparer);
            HashSet <AuthorizationRule>       comparandRules   = new HashSet <AuthorizationRule>(comparand.innerCollection, equalityComparer);

            if (thisRules.Count != comparandRules.Count)
            {
                return(false);
            }

            foreach (AuthorizationRule rule in thisRules)
            {
                if (!comparandRules.Contains(rule))
                {
                    return(false);
                }
            }

            return(true);
        }