/// <summary> /// Fills the endpoint by URI. /// </summary> /// <param name="uri">The URI.</param> /// <param name="endpoint">The endpoint.</param> protected static void FillEndpointByUri(Uri uri, UriEndpoint endpoint) { if (uri != null && endpoint != null) { endpoint.Protocol = uri.Scheme; endpoint.Host = uri.Host; endpoint.Port = uri.IsDefaultPort ? null : uri.Port as int?; endpoint.Path = "/" + uri.AbsolutePath.TrimStart('/').SubStringBeforeFirstMatch('/'); } }
/// <summary> /// Determines whether the specified <see cref="System.Object" />, is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { UriEndpoint endpoint = obj as UriEndpoint; return(endpoint != null && endpoint.Protocol.SafeEquals(Protocol, StringComparison.OrdinalIgnoreCase) && endpoint.Host.SafeEquals(Host, StringComparison.OrdinalIgnoreCase) && endpoint.Port.SafeEquals(Port) && endpoint.Path.MeaningfulEquals(Path, StringComparison.OrdinalIgnoreCase)); }