예제 #1
0
        private EssContext Create(MergeOption mergeOption)
        {
            var ctx = odataClientFactory.CreateClient <EssContext>(dynamicsOptions.DynamicsApiBaseUri, "dynamics");

            ctx.MergeOption = mergeOption;
            return(ctx);
        }
예제 #2
0
        internal void TestHappyCase()
        {
            counter.ODataInvokeCount.Should().Be(0);
            var client = factory.CreateClient <DefaultContainer>(new Uri("http://localhost"), "Verification");

            client.Configurations.Properties.Add("api-version", "1.0");

            counter.ODataInvokeCount.Should().Be(1);
            counter.HttpInvokeCount.Should().Be(0);

            Func <Task> task = async() => await client.Person.GetAllPagesAsync();

            task.ShouldThrow <InvalidOperationException>("No one is listen to that Url.");

            counter.ODataInvokeCount.Should().Be(1);
            counter.HttpInvokeCount.Should().Be(1);
        }
예제 #3
0
        internal void TestHappyCase()
        {
            counter.ODataInvokeCount.Should().Be(0);
            var client = factory.CreateClient <DataServiceContext>(new Uri("http://localhost"), "Verification");

            /*
             * TODO: uncomment this after properties is supported.
             * client.Configurations.Properties.Add("api-version", "1.0");
             *
             * counter.ODataInvokeCount.Should().Be(1);
             * counter.HttpInvokeCount.Should().Be(0);
             *
             * Func<Task> task = async() => await client.Person.GetAllPagesAsync();
             * task.ShouldThrow<InvalidOperationException>("No one is listen to that Url.");
             *
             * counter.ODataInvokeCount.Should().Be(1);
             * counter.HttpInvokeCount.Should().Be(1);
             */
        }
예제 #4
0
 /// <summary>
 /// Creates and configures an <see cref="DataServiceContext"/> instance using the configuration that corresponds
 /// to the logical name specified by <see cref="ODataClientOptions.DefaultName"/> with the specified <paramref name="serviceRoot" />
 /// </summary>
 /// <typeparam name="T">The concrate OData client type generated from OData Client code generator.</typeparam>
 /// <param name="factory">The factory used to create the odata client.</param>
 /// <param name="serviceRoot">An absolute URI that identifies the root of a data service.</param>
 /// <returns>A new <see cref="DataServiceContext"/> instance.</returns>
 /// <remarks>
 /// <para>
 /// Each call to <see cref="IODataClientFactory.CreateClient{T}(Uri, string)"/> is guaranteed to return a new <see cref="DataServiceContext"/>
 /// instance.
 /// </para>
 /// <para>
 /// Callers are also free to mutate the returned <see cref="DataServiceContext"/> instance's public properties
 /// as desired.
 /// </para>
 /// </remarks>
 public static T CreateClient <T>(this IODataClientFactory factory, Uri serviceRoot) where T : DataServiceContext
 {
     return(factory.CreateClient <T>(serviceRoot, ODataClientOptions.DefaultName));
 }
예제 #5
0
 public ODataServiceContext Create(string url)
 {
     return(clientFactory.CreateClient <ODataServiceContext>(new Uri(url)));
 }