Ejemplo n.º 1
0
        public async Task <HttpClient> CreateAsync()
        {
            var auth = await _factory.CreateAsync();

            var client = _handler != null ? new HttpClient(_handler) : new HttpClient();

            client.BaseAddress = _api.Url;
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"{auth?.CurrentUser?.IdToken ?? "NULL"}");

            return(client);
        }
        public AsyncCache(
            IAsyncFactory <TKey, ICacheValue <TKey, TValue> > factory,
            IEqualityComparer <TKey> comparer)
        {
            Contracts.Requires.That(factory != null);
            Contracts.Requires.That(comparer != null);

            this.cache = new AsyncCache <TKey, VoidStruct, TValue>(
                Factory.FromAsync((TKey key, VoidStruct unused) => factory.CreateAsync(key)),
                comparer);
        }
        public ContourMeshFactory(
            IRasterChunkConfig <Index3D> voxelChunkConfig,
            IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory,
            IPool <IMutableDivisibleMesh <NormalColorTextureVertex> > meshBuilderPool,
            IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer)
        {
            Contracts.Requires.That(voxelChunkConfig != null);
            Contracts.Requires.That(voxelChunkFactory != null);
            Contracts.Requires.That(meshBuilderPool != null);
            Contracts.Requires.That(contourer != null);

            this.voxelChunkDimensionsInVoxels = voxelChunkConfig.Bounds.Dimensions;
            this.meshBuilderPool = meshBuilderPool;
            this.contourer       = contourer;

            this.chunkConglomerator = new ChunkConglomerator <IReadOnlyVoxelGridChunk>(
                async index => await voxelChunkFactory.CreateAsync(
                    new ChunkKey(index - new Index3D(1))).DontMarshallContext(),
                new Index3D(3));
        }
Ejemplo n.º 4
0
 public async Task <TEntity> Entity(Guid id, Func <DataServiceQuery <TEntity>, IQueryable <TEntity> > selector) =>
 (await selector(Entities).Where(u => u.Id == id).ToListAsync(await _factory.CreateAsync())).Value.FirstOrDefault();