IAsyncAdapter CreateAsyncAdapter()
        {
            if (Sync)
            {
                return(AsyncOverSyncAdapter.Instance);
            }

            var providerType = Provider.GetType();

            var customAdapter = CustomAsyncAdapters.GetAdapter(providerType);

            if (customAdapter != null)
            {
                return(customAdapter);
            }

            if (ReflectionAsyncAdapter.SupportsProvider(ProviderInfo))
            {
                return(new ReflectionAsyncAdapter(ProviderInfo));
            }

            if (AllowAsyncOverSync)
            {
                return(AsyncOverSyncAdapter.Instance);
            }

            throw ProviderNotSupported(providerType);
        }
Beispiel #2
0
        IAsyncAdapter CreateAsyncAdapter()
        {
            if (Sync)
            {
                return(AsyncOverSyncAdapter.Instance);
            }

            return(CustomAsyncAdapters.GetAdapter(Provider.GetType())
                   ?? new ReflectionAsyncAdapter(ProviderInfo));
        }
Beispiel #3
0
        public async Task RegisterAdapter()
        {
            try {
                var adapter = new MyAdapter();
                CustomAsyncAdapters.RegisterAdapter(typeof(EnumerableQuery), adapter);

                await DataSourceLoader.LoadAsync(SAMPLE_DATA, new SampleLoadOptions {
                    RequireTotalCount = true
                });

                Assert.True(adapter.CountCalled);
                Assert.True(adapter.ToEnumerableCalled);
            } finally {
                CustomAsyncAdapters.Clear();
            }
        }