コード例 #1
0
        /// <summary>
        /// Gets The service metadata as string asynchronous.
        /// </summary>
        /// <param name="urlBase">The URL base.</param>
        /// <param name="credentials">The OData service access credentials.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The service metadata.</returns>
        public static async Task <string> GetMetadataAsStringAsync(string urlBase, ICredentials credentials, CancellationToken cancellationToken)
        {
            var session = Session.FromSettings(new ODataClientSettings(urlBase, credentials));
            await session.ResolveAdapterAsync(cancellationToken);

            return(session.MetadataCache.MetadataAsString);
        }
コード例 #2
0
        /// <summary>
        /// Retrieves the OData service metadata.
        /// </summary>
        /// <typeparam name="T">OData protocol specific metadata interface</typeparam>
        /// <param name="urlBase">The URL base of the OData service.</param>
        /// <param name="credentials">The OData service access credentials.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The service metadata.
        /// </returns>
        public static async Task <T> GetMetadataAsync <T>(string urlBase, ICredentials credentials, CancellationToken cancellationToken)
        {
            var session = Session.FromSettings(new ODataClientSettings(urlBase, credentials));
            await session.ResolveAdapterAsync(cancellationToken);

            return((T)session.Adapter.Model);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataClient"/> class.
 /// </summary>
 /// <param name="settings">The OData client settings.</param>
 public ODataClient(ODataClientSettings settings)
 {
     _settings      = settings;
     _session       = Session.FromSettings(_settings);
     _requestRunner = new RequestRunner(_session);
 }