/// <summary> /// Returns true if ComAdobeCqDamWebdavImplIoAssetIOHandlerProperties instances are equal /// </summary> /// <param name="other">Instance of ComAdobeCqDamWebdavImplIoAssetIOHandlerProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(ComAdobeCqDamWebdavImplIoAssetIOHandlerProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ServiceRanking == other.ServiceRanking || ServiceRanking != null && ServiceRanking.Equals(other.ServiceRanking) ) && ( PathPrefix == other.PathPrefix || PathPrefix != null && PathPrefix.Equals(other.PathPrefix) ) && ( CreateVersion == other.CreateVersion || CreateVersion != null && CreateVersion.Equals(other.CreateVersion) )); }
public IRoute Map(PathPrefix route, Type pipelineType) { var instance = new Route(route, pipelineType); Add(instance); return(instance); }
public IRoute Map <T>(PathPrefix route) where T : IPipeline { var instance = new Route(route, typeof(T)); Add(instance); return(instance); }
public Route(PathPrefix path, Type pipelineType) { if (!typeof(IPipeline).IsAssignableFrom(pipelineType)) { throw new InvalidCastException($"O tipo {pipelineType.GetType().FullName} não implementa a interface {typeof(IPipeline).FullName}."); } this.Path = path ?? throw new NullReferenceException("Uma rota não pode ser criada com um prefixo de caminho nulo: path=(null)"); this.Type = pipelineType; }
public override int GetHashCode() { int hash = 1; if (PathPrefix.Length != 0) { hash ^= PathPrefix.GetHashCode(); } if (Format != 0) { hash ^= Format.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ServiceRanking != null) { hashCode = hashCode * 59 + ServiceRanking.GetHashCode(); } if (PathPrefix != null) { hashCode = hashCode * 59 + PathPrefix.GetHashCode(); } if (CreateVersion != null) { hashCode = hashCode * 59 + CreateVersion.GetHashCode(); } return(hashCode); } }
/// <summary> /// Validates the frontend. /// </summary> /// <param name="context">The validation context.</param> /// <param name="rule">The parent rule.</param> public void Validate(TrafficValidationContext context, TrafficHttpRule rule) { base.Validate(context, rule); if (rule.Frontends.Count > 1 || !string.IsNullOrEmpty(CertName) || ProxyPort == 0 || ProxyPort == HiveHostPorts.ProxyPublicHttp || ProxyPort == HiveHostPorts.ProxyPublicHttps || ProxyPort == HiveHostPorts.ProxyPrivateHttp || ProxyPort == HiveHostPorts.ProxyPrivateHttps) { // The hostname is required so verify it. if (string.IsNullOrEmpty(Host)) { context.Error($"Rule [{rule.Name}] has a frontend without a [{nameof(Host)}] specified. HTTP rules targeting the default traffic manager HTTP/S ports, with more than one frontend, or secured by TLS requires frontend hostnames."); } else if (!HiveDefinition.DnsHostRegex.IsMatch(Host)) { context.Error($"Rule [{rule.Name}] defines the invalid hostname [{Host}]."); } } else { // The hostname is not required but verify it if one is specified. if (!string.IsNullOrEmpty(Host) && !HiveDefinition.DnsHostRegex.IsMatch(Host)) { context.Error($"Rule [{rule.Name}] defines the invalid hostname [{Host}]."); } } if (!string.IsNullOrEmpty(PathPrefix)) { if (!PathPrefix.StartsWith("/")) { context.Error($"Rule [{rule.Name}] references has [{nameof(PathPrefix)}={PathPrefix}] that does not begin with a forward slash."); } else { if (!PathPrefix.EndsWith("/")) { PathPrefix += "/"; } if (!Uri.TryCreate(PathPrefix, UriKind.Relative, out Uri uri)) { context.Error($"Rule [{rule.Name}] references has [{nameof(PathPrefix)}={PathPrefix}] that is not a valid relative URI."); } } } if (CertName != null && context.ValidateCertificates) { TlsCertificate certificate; if (!context.Certificates.TryGetValue(CertName, out certificate)) { context.Error($"Rule [{rule.Name}] references certificate [{CertName}] that does not exist or could not be loaded."); } else { if (!certificate.IsValidHost(Host)) { context.Error($"Rule [{rule.Name}] references certificate [{CertName}] which does not cover host [{Host}]."); } if (!certificate.IsValidDate(DateTime.UtcNow)) { context.Error($"Rule [{rule.Name}] references certificate [{CertName}] which expired on [{certificate.ValidUntil}]."); } } } if (ProxyPort != 0) { if (!context.Settings.ProxyPorts.IsValidPort(ProxyPort)) { context.Error($"Rule [{rule.Name}] assigns [{nameof(ProxyPort)}={ProxyPort}] which is outside the range of valid frontend ports for this traffic manager [{context.Settings.ProxyPorts}]."); } } else { if (CertName == null) { ProxyPort = context.Settings.DefaultHttpPort; } else { ProxyPort = context.Settings.DefaultHttpsPort; } } if (PublicPort == -1) { if (CertName == null) { PublicPort = NetworkPorts.HTTP; } else { PublicPort = NetworkPorts.HTTPS; } } if (PublicPort > 0 && !NetHelper.IsValidPort(PublicPort)) { context.Error($"Load balancer [{nameof(PublicPort)}={PublicPort}] is not a valid network port."); } if (RedirectTo != null) { // Strip off the path/query part of the URI, if necessary. if (RedirectTo.PathAndQuery != "/") { RedirectTo = new Uri($"{RedirectTo.Scheme}://{RedirectTo.Host}:{RedirectTo.Port}/"); } } }
public bool Equals(Node node) => PathPrefix.Equals(node.PathPrefix) && NodeName.Equals(node.NodeName) && IsFileNode.Equals(node.IsFileNode);