예제 #1
0
        internal ServiceDescriptor(
            List <string> metadataFiles,
            IHttpCredentialsProvider userCredentialsProvider,
            IClientCertificateProvider clientCertificateProvider,
            IServerCertificateValidationProvider serverCertificateValidationProvider)
        {
            if (metadataFiles == null)
            {
                throw new ArgumentException(nameof(metadataFiles));
            }

            this.metadataDocumentLoader = new MetadataDocumentLoader(metadataFiles, false, userCredentialsProvider, clientCertificateProvider, serverCertificateValidationProvider);
        }
예제 #2
0
        internal ServiceDescriptor(
            string serviceUri,
            IHttpCredentialsProvider userCredentialsProvider,
            IClientCertificateProvider clientCertificateProvider,
            IServerCertificateValidationProvider serverCertificateValidationProvider)
        {
            if (string.IsNullOrWhiteSpace(serviceUri))
            {
                throw new ArgumentException(nameof(serviceUri));
            }

            this.metadataDocumentLoader = new MetadataDocumentLoader(serviceUri, userCredentialsProvider, clientCertificateProvider, serverCertificateValidationProvider);
        }
예제 #3
0
        private async Task <bool> ResolveMetadataAsync(Stream stream, string baseUri, CancellationToken cancellationToken)
        {
            var loader = new MetadataDocumentLoader(baseUri, this.HttpCredentialsProvider, this.ClientCertificatesProvider, this.ServerCertificateValidationProvider);

            try
            {
                await loader.LoadFromStreamAsync(stream, baseUri, string.Empty, cancellationToken).ConfigureAwait(false);

                _metadataSet = new MetadataSet(loader.MetadataSections);
            }
            catch
            {
            }

            return(this.HasServiceMetadata);
        }
예제 #4
0
        /// <summary>
        /// Creates a ServiceDescriptor instance or retrieve an existing one that has imported its metadata already.
        /// </summary>
        /// <param name="uri"></param>
        /// <returns></returns>
        private ServiceDescriptor Get(MetadataDocumentLoader metadaDocLoader)
        {
            ServiceDescriptor serviceDescriptor;
            var key = metadaDocLoader.GetHashCode();

            lock (_cacheLock)
            {
                if (_cache.ContainsKey(key) && _cache[key].MetadataImported)
                {
                    serviceDescriptor = _cache[key];
                }
                else
                {
                    serviceDescriptor = CreateServiceDescriptor(metadaDocLoader);
                    _cache[key]       = serviceDescriptor;
                }
            }

            return(serviceDescriptor);
        }
예제 #5
0
 protected virtual ServiceDescriptor CreateServiceDescriptor(MetadataDocumentLoader metadaDocLoader)
 {
     return(new ServiceDescriptor(metadaDocLoader));
 }
예제 #6
0
 internal ServiceDescriptor(MetadataDocumentLoader metadataDocumentLoader)
 {
     this.metadataDocumentLoader = metadataDocumentLoader ?? throw new ArgumentNullException(nameof(metadataDocumentLoader));
 }