// Total number of children left, not capped by _maxChildren.
        async Task <int> CountChildrenUncappedAsync()
        {
            if (_entity is IHasChildrenLimit entityWithChildrenLimit)
            {
                entityWithChildrenLimit.ChildrenLimit = _offset + _maxChildren + 1;
            }

            return(await _entity.CountChildrenAsync() - _offset);
        }
        public static async Task <IVariableInformation[]> GetAllChildrenAsync(
            this IVariableInformation varInfo)
        {
            IChildAdapter childAdapter = varInfo.GetChildAdapter();

            return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
                   .ToArray());
        }
Example #3
0
        protected override async Task <int> InitChildrenCountAsync()
        {
            if (string.IsNullOrWhiteSpace(_expandedItem?.Value))
            {
                return(0);
            }

            await InitChildAdapterAsync();

            return(await _childAdapter.CountChildrenAsync());
        }
Example #4
0
 async Task <string[]> GetAllChildFormatSpecifiersAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.FormatSpecifier)
            .ToArray());
 }
Example #5
0
 async Task <string[]> GetAllChildNamesAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.DisplayName)
            .ToArray());
 }
        public async Task <int> CountChildrenAsync()
        {
            await InitAsync();

            return(await _adapter.CountChildrenAsync());
        }
        static async Task <string> FormatChildrenListAsync(IVariableInformation varInfo,
                                                           int charactersLeft,
                                                           string noChildrenMarker = "")
        {
            IChildAdapter children = varInfo.GetChildAdapter();

            if (children is INatvisEntity)
            {
                return("");
            }

            int childrenCount = await children.CountChildrenAsync();

            const int     maxChildren = 3;
            StringBuilder sb          = new StringBuilder();

            sb.Append("{");
            for (int i = 0; i < childrenCount; i++)
            {
                try
                {
                    IVariableInformation currentChild =
                        (await children.GetChildrenAsync(i, 1)).ElementAt(0).GetCachedView();

                    // For array elements or pointers, we do not display the child name.
                    // Also array elements are separated by commas. We detect the array elements
                    // using a somewhat hacky way - we check if their name is the index in
                    // square brackets.
                    bool isArrayElementOrPointee =
                        currentChild.DisplayName == $"[{i}]" || currentChild.DisplayName == "";

                    if (i != 0)
                    {
                        sb.Append(isArrayElementOrPointee ? ", " : " ");
                    }

                    // If we are over the limit, let us just display the dots and exit.
                    if (!isArrayElementOrPointee && i >= maxChildren)
                    {
                        sb.Append("...");
                        break;
                    }

                    string childValue =
                        await BuildAsync(currentChild, charactersLeft - sb.Length - 1);

                    if (string.IsNullOrEmpty(childValue) && currentChild.GetChildAdapter()
                        is INatvisEntity)
                    {
                        childValue = "{...}";
                    }
                    else if (childValue == "..." || string.IsNullOrEmpty(childValue))
                    {
                        sb.Append(childValue);
                        break;
                    }

                    if (!isArrayElementOrPointee)
                    {
                        sb.Append($"{currentChild.DisplayName}=");
                    }
                    sb.Append(childValue);
                }
                catch (ArgumentOutOfRangeException)
                {
                    break;
                }
            }
            if (childrenCount == 0)
            {
                sb.Append(noChildrenMarker);
            }
            sb.Append("}");
            return(sb.ToString());
        }
 public async Task <int> GetChildrenCountAsync() => await _childAdapter.CountChildrenAsync();