예제 #1
0
            private async Task <IUntypedReadableProperty> GetNextPropertyAsync(CancellationToken cancellationToken)
            {
                if (!_predefinedPropertiesFinished)
                {
                    if (_predefinedPropertiesEnumerator.MoveNext())
                    {
                        return(_predefinedPropertiesEnumerator.Current);
                    }

                    _predefinedPropertiesFinished = true;

                    if (_propertyStore == null || (_maxCost.HasValue && _propertyStore.Cost > _maxCost))
                    {
                        return(null);
                    }

                    var deadProperties = await _propertyStore.LoadAsync(_entry, cancellationToken).ConfigureAwait(false);

                    _deadPropertiesEnumerator = deadProperties.GetEnumerator();
                }

                if (_propertyStore == null || (_maxCost.HasValue && _propertyStore.Cost > _maxCost))
                {
                    return(null);
                }

                Debug.Assert(_deadPropertiesEnumerator != null, "_deadPropertiesEnumerator != null");
                if (_deadPropertiesEnumerator == null)
                {
                    throw new InvalidOperationException("Internal error: The dead properties enumerator was not initialized");
                }
                if (!_deadPropertiesEnumerator.MoveNext())
                {
                    return(null);
                }

                return(_deadPropertiesEnumerator.Current);
            }