Ejemplo n.º 1
0
        public async Task <IODataAdapter> ResolveAdapterAsync(CancellationToken cancellationToken)
        {
            if (this.MetadataCache == null)
            {
                string metadataDocument = Settings.MetadataDocument;
                if (string.IsNullOrEmpty(metadataDocument))
                {
                    metadataDocument = await ResolveMetadataAsync(cancellationToken).ConfigureAwait(false);
                }
                this.MetadataCache =
                    MetadataCache.GetOrAdd(
                        this.Settings.BaseUri.AbsoluteUri,
                        uri =>
                {
                    var cache = new MetadataCache(uri, metadataDocument);
                    return(cache);
                });
            }

            if (this.Settings.PayloadFormat == ODataPayloadFormat.Unspecified)
            {
                this.Settings.PayloadFormat = this.Adapter.DefaultPayloadFormat;
            }

            return(this.Adapter);
        }
Ejemplo n.º 2
0
        public async Task <IODataAdapter> ResolveAdapterAsync(CancellationToken cancellationToken)
        {
            if (this.MetadataCache == null)
            {
                this.MetadataCache =
                    MetadataCache.GetOrAdd(
                        this.Settings.BaseUri.AbsoluteUri,
                        uri =>
                {
                    var cache = new MetadataCache(uri);
                    cache.SetMetadataDocument(ResolveMetadataAsync(cancellationToken));

                    return(cache);
                });
            }

            await this.MetadataCache.Resolved;

            if (this.Settings.PayloadFormat == ODataPayloadFormat.Unspecified)
            {
                this.Settings.PayloadFormat = this.Adapter.DefaultPayloadFormat;
            }

            return(this.Adapter);
        }
Ejemplo n.º 3
0
 private Session(Uri baseUri, string metadataString)
 {
     this.Settings         = new ODataClientSettings();
     this.Settings.BaseUri = baseUri;
     this.MetadataCache    = MetadataCache.GetOrAdd(baseUri.AbsoluteUri, uri => new MetadataCache(uri, metadataString));
     this.Pluralizer       = new SimplePluralizer();
 }
Ejemplo n.º 4
0
 private Session(Uri baseUri, string metadataString)
 {
     this.Settings = new ODataClientSettings {
         BaseUri = baseUri
     };
     this.MetadataCache = MetadataCache.GetOrAdd(baseUri.AbsoluteUri, uri => new MetadataCache(uri, metadataString));
 }
Ejemplo n.º 5
0
        public void ClearMetadataCache()
        {
            var metadataCache = this.MetadataCache;

            if (metadataCache != null)
            {
                MetadataCache.Clear(metadataCache.Key);
                this.MetadataCache = null;
            }
        }
Ejemplo n.º 6
0
        private Session(ODataClientSettings settings)
        {
            if (settings.BaseUri == null || string.IsNullOrEmpty(settings.BaseUri.AbsoluteUri))
            {
                throw new InvalidOperationException("Unable to create client session with no URI specified.");
            }

            this.Settings = settings;
            if (!string.IsNullOrEmpty(settings.MetadataDocument))
            {
                this.MetadataCache = MetadataCache.GetOrAdd(this.Settings.BaseUri.AbsoluteUri, uri => new MetadataCache(uri, settings.MetadataDocument));
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Clears service metadata cache.
 /// </summary>
 public static void ClearMetadataCache()
 {
     MetadataCache.Clear();
 }