public override void GetQueryFormat(IReadOnlyEntity entity, QueryFormat format)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            foreach (var handler in Handlers)
            {
                handler.GetQueryFormat(entity, format);
            }
        }
Exemple #2
0
        internal Task RequestQueryFormatAsync(
            ComponentTypeCode[] componentFilter,
            RequestQueryFormatProgressDelegate requestQueryFormatProgressDelegate,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (componentFilter == null)
            {
                throw new ArgumentNullException(nameof(componentFilter));
            }

            return(Task.Run(() =>
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                var format = new QueryFormat();
                format.Changed += (sender, e) =>
                {
                    requestQueryFormatProgressDelegate?.Invoke(e.Action);
                };

                var componentFilter2 = new ReadOnlyComponentFilter(componentFilter);

                using (var e = volatileDatabaseItems.GetEnumerator(cancellationToken))
                {
                    foreach (var entity in e.AsEnumerable().Where(i => i.HasComponents(componentFilter)))
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        var readOnlyEntity = entity.AsReadOnly(componentFilter2);
                        QueryHandler.GetQueryFormat(readOnlyEntity, format);
                    }
                }
            }, cancellationToken));
        }