コード例 #1
0
 /// <summary>
 /// Returns true if this registration matches the endpoint
 /// model provided.
 /// </summary>
 /// <param name="endpoint"></param>
 /// <returns></returns>
 public bool Matches(EndpointModel endpoint)
 {
     return(endpoint != null &&
            EndpointUrl == endpoint.Url &&
            AlternativeUrls.DecodeAsList().ToHashSetSafe().SetEqualsSafe(
                endpoint.AlternativeUrls) &&
            CredentialType == (endpoint.User?.Type ?? Models.CredentialType.None) &&
            JToken.DeepEquals(Credential, endpoint.User?.Value) &&
            SecurityMode == (endpoint.SecurityMode ?? Models.SecurityMode.Best) &&
            SecurityPolicy == endpoint.SecurityPolicy &&
            endpoint.ClientCertificate.SequenceEqualsSafe(
                ClientCertificate.DecodeAsByteArray()) &&
            endpoint.ServerThumbprint.SequenceEqualsSafe(
                ServerThumbprint.DecodeAsByteArray()));
 }
コード例 #2
0
 /// <summary>
 /// Flag endpoint as synchronized - i.e. it matches the other.
 /// </summary>
 /// <param name="other"></param>
 internal void MarkAsInSyncWith(EndpointRegistration other)
 {
     _isInSync =
         other != null &&
         EndpointUrl == other.EndpointUrl &&
         AlternativeUrls.DecodeAsList().ToHashSetSafe().SetEqualsSafe(
             other.AlternativeUrls.DecodeAsList()) &&
         CredentialType == other.CredentialType &&
         JToken.DeepEquals(Credential, other.Credential) &&
         SecurityPolicy == other.SecurityPolicy &&
         SecurityMode == other.SecurityMode &&
         ClientCertificate.DecodeAsByteArray().SequenceEqualsSafe(
             other.ClientCertificate.DecodeAsByteArray()) &&
         ServerThumbprint.DecodeAsByteArray().SequenceEqualsSafe(
             other.ServerThumbprint.DecodeAsByteArray());
 }
コード例 #3
0
 /// <summary>
 /// Convert to service model
 /// </summary>
 /// <returns></returns>
 public EndpointInfoModel ToServiceModel()
 {
     return(new EndpointInfoModel {
         ApplicationId = ApplicationId,
         Registration = new EndpointRegistrationModel {
             Id = DeviceId,
             SiteId = string.IsNullOrEmpty(SiteId) ?
                      null : SiteId,
             SupervisorId = string.IsNullOrEmpty(SupervisorId) ?
                            null : SupervisorId,
             Certificate = Certificate.DecodeAsByteArray(),
             AuthenticationMethods = AuthenticationMethods?.DecodeAsList(j =>
                                                                         j.ToObject <AuthenticationMethodModel>()),
             SecurityLevel = SecurityLevel,
             EndpointUrl = string.IsNullOrEmpty(EndpointRegistrationUrl) ?
                           (string.IsNullOrEmpty(EndpointUrl) ?
                            EndpointUrlLC : EndpointUrl) : EndpointRegistrationUrl,
             Endpoint = new EndpointModel {
                 Url = string.IsNullOrEmpty(EndpointUrl) ?
                       EndpointUrlLC : EndpointUrl,
                 AlternativeUrls = AlternativeUrls?.DecodeAsList().ToHashSetSafe(),
                 User = CredentialType == null ? null :
                        new CredentialModel {
                     Value = Credential,
                     Type = CredentialType == Models.CredentialType.None ?
                            null : CredentialType
                 },
                 SecurityMode = SecurityMode == Models.SecurityMode.Best ?
                                null : SecurityMode,
                 SecurityPolicy = string.IsNullOrEmpty(SecurityPolicy) ?
                                  null : SecurityPolicy,
                 ClientCertificate = ClientCertificate.DecodeAsByteArray(),
                 ServerThumbprint = ServerThumbprint.DecodeAsByteArray()
             }
         },
         ActivationState = ActivationState,
         NotSeenSince = NotSeenSince,
         EndpointState = ActivationState == EndpointActivationState.ActivatedAndConnected ?
                         State : (EndpointConnectivityState?)null,
         OutOfSync = Connected && !_isInSync ? true : (bool?)null
     });
 }