/// <summary>
        /// Compare two Sids.
        /// </summary>
        /// <param name="obj">The other Sid to compare.</param>
        /// <returns>True if the Sids are equal.</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is Sid))
            {
                return(false);
            }

            Sid sid = obj as Sid;

            if (!Authority.Equals(sid.Authority))
            {
                return(false);
            }

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

            for (int i = 0; i < this.SubAuthorities.Count; ++i)
            {
                if (SubAuthorities[i] != sid.SubAuthorities[i])
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        ///     Returns true if MsalAuthParameters instances are equal
        /// </summary>
        /// <param name="other">Instance of MsalAuthParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MsalAuthParameters other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((ClientApplicationId == other.ClientApplicationId ||
                  ClientApplicationId != null && ClientApplicationId.Equals(other.ClientApplicationId)) &&
                 (ClientId == other.ClientId || ClientId != null && ClientId.Equals(other.ClientId)) &&
                 (Authority == other.Authority || Authority != null && Authority.Equals(other.Authority)) &&
                 (RedirectUri == other.RedirectUri || RedirectUri != null && RedirectUri.Equals(other.RedirectUri)) &&
                 (RequestedScopes == other.RequestedScopes ||
                  RequestedScopes != null && RequestedScopes.Equals(other.RequestedScopes)) &&
                 (Username == other.Username || Username != null && Username.Equals(other.Username)) &&
                 (Password == other.Password || Password != null && Password.Equals(other.Password)) &&
                 (TelemetryCorrelationId == other.TelemetryCorrelationId || TelemetryCorrelationId != null &&
                  TelemetryCorrelationId.Equals(other.TelemetryCorrelationId)) &&
                 (AuthorizationType == other.AuthorizationType ||
                  AuthorizationType != null && AuthorizationType.Equals(other.AuthorizationType)));
        }
 /// <summary>
 /// Checks if the SID starts with the specified SID.
 /// </summary>
 /// <param name="sid">The specified SID to check against.</param>
 /// <returns>True if the current SID starts with the specified SID.</returns>
 public bool StartsWith(Sid sid)
 {
     if (!Authority.Equals(sid.Authority))
     {
         return(false);
     }
     if (sid.SubAuthorities.Count > SubAuthorities.Count)
     {
         return(false);
     }
     for (int i = 0; i < sid.SubAuthorities.Count; i++)
     {
         if (sid.SubAuthorities[i] != SubAuthorities[i])
         {
             return(false);
         }
     }
     return(true);
 }