Esempio n. 1
0
        public static string UrlEncoded(this AuthScope self)
        {
            var sb = new StringBuilder();

            foreach (var item in self.Items)
            {
                sb.Append(item);
                sb.Append('+');
            }

            return(sb.ToString().TrimEnd('+'));
        }
Esempio n. 2
0
        private bool isEqual(AuthScope other)
        {
            if (IsEmpty)
            {
                return(other.IsEmpty);
            }

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

            return(Items.All(scope => other.Items.Any(i => i.Equals(scope, StringComparison.InvariantCultureIgnoreCase))));
        }
Esempio n. 3
0
        /// <summary>
        ///   Adds one or more scope identifiers to the <see cref="AuthConfig.Scope"/> value.
        /// </summary>
        /// <returns>
        ///   <c>this</c>
        /// </returns>
        public static AuthConfig WithScope(this AuthConfig self, AuthScope scope)
        {
            self.Scope = scope;
            return(self);

            /* obsolete
             * var strings = self.Scope?.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries) ?? new string[0];
             * var current = new HashSet<string>(strings);
             * var sb = new StringBuilder(self.Scope);
             * foreach (var identifier in scope.Where(i => !current.Contains(i)))
             * {
             *  sb.Append($"{identifier.Trim()} ");
             * }
             *
             * self.Scope = sb.ToString().Trim();
             * return self;
             */
        }
Esempio n. 4
0
 /// <summary>
 ///   Removes one or more scope types from the <see cref="AuthConfig.Scope"/> value.
 /// </summary>
 /// <returns>
 ///   <c>this</c>
 /// </returns>
 public static AuthConfig RemoveScope(this AuthConfig self, AuthScope scope) => self.RemoveScope(scope.Items);
Esempio n. 5
0
 /// <summary>
 ///   Adds one or more scope types (not already supported) to the <see cref="AuthConfig.Scope"/> value.
 /// </summary>
 /// <returns>
 ///   <c>this</c>
 /// </returns>
 public static AuthConfig AddScope(this AuthConfig self, AuthScope scope) => self.AddScope(scope.Items);