Esempio n. 1
0
 private Session(Uri baseUri, string metadataString)
 {
     this.Settings = new ODataClientSettings {
         BaseUri = baseUri
     };
     this.MetadataCache = MetadataCache.GetOrAdd(baseUri.AbsoluteUri, uri => new MetadataCache(uri, metadataString));
 }
        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);
        }
 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();
 }