public static bool Any <T>(this IGetStatisticsGrain <T> src, Func <T, bool> func)
            where T : DataChunk
        {
            var task = src.GetAllSerialized();

            task.Wait();

            return(JsonConvert.DeserializeObject <ICollection <T> >(task.Result).Any(x => func(x)));
        }
Example #2
0
        public async Task Setup()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", true, true)
                                .Build();

            configuration.GetSection("OskSettings").Bind(_oskSettings);

            _mongoUtils         = new MongoUtils(_oskSettings);
            _addStatisticsGrain = new MongoManageStatisticsGrain <TestModel>(_mongoUtils);
            _getStatisticsGrain = new MongoGetStatisticsGrain <TestModel>(_mongoUtils, new NLogLogger());
            _grainsContext      = new GenericGrainsContext();
            _logger             = new NLogLogger();
            _executiveGrain     = new GenericExecutiveGrain(new MemoryAssemblyMembersCache(new MemoryAssemblyCache()), _logger);
            //var clt = new ClientStartup();
            //var client = await clt.StartClientWithRetries();
            //_grainsExecutivePool = new GrainsExecutivePool(client, 10);
            await FillData();
        }
 public static async Task <IEnumerable <T> > Where <T>(this IGetStatisticsGrain <T> src, Func <T, bool> func)
     where T : DataChunk
 => (JsonConvert.DeserializeObject <ICollection <T> >(await src.GetAllSerialized())).Where(x => func(x));
 public static async Task <bool> AnyAsync <T>(this IGetStatisticsGrain <T> src, Func <T, bool> func)
     where T : DataChunk
 => JsonConvert.DeserializeObject <ICollection <T> >(await src.GetAllSerialized()).Any(x => func(x));
 public static async Task <ICollection <T> > GetLastN <T>(this IGetStatisticsGrain <T> src, Func <T, bool> func, int elems)
     where T : DataChunk
 => JsonConvert.DeserializeObject <ICollection <T> >(await src.GetAllSerialized())?.Where(x => func(x)).TakeLast(elems).ToArray();