public static async Task <IVariableInformation[]> GetAllChildrenAsync(
            this IVariableInformation varInfo)
        {
            IChildAdapter childAdapter = varInfo.GetChildAdapter();

            return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
                   .ToArray());
        }
        public async Task <int> GetChildrenAsync(int fromIndex, int requestedCount,
                                                 DEBUG_PROPERTY_INFO[] outPropertyInfo)
        {
            IList <IVariableInformation> children =
                await _childAdapter.GetChildrenAsync(fromIndex, requestedCount);

            List <IGgpDebugProperty> debugProperties = children
                                                       .Select(c => _createPropertyDelegate.Invoke(c)).ToList();

            for (int i = 0; i < debugProperties.Count; i++)
            {
                outPropertyInfo[i] = await CreatePropertyInfoAsync(debugProperties[i]);
            }

            return(debugProperties.Count);
        }
Exemple #3
0
        public override async Task <IList <IVariableInformation> > GetChildrenAsync(
            int from, int count)
        {
            await InitAsync();

            if (await CountChildrenAsync() == 0)
            {
                return(new List <IVariableInformation>());
            }

            if (_store.ValidationError != null)
            {
                return(new List <IVariableInformation>()
                {
                    _store.ValidationError
                }.GetRange(
                           from, count));
            }

            return(await _childAdapter.GetChildrenAsync(from, count));
        }
        public async Task <IList <IVariableInformation> > GetChildrenAsync(int from, int count)
        {
            from = Math.Max(0, from);

            int entityFrom  = _offset + from;
            int entityCount = Math.Min(await CountChildrenWithoutMoreAsync() - from, count);

            if (entityCount < 0)
            {
                return(new List <IVariableInformation>());
            }

            IList <IVariableInformation> result =
                await _entity.GetChildrenAsync(entityFrom, entityCount);

            if (await HasMoreAsync() && count > entityCount)
            {
                result.Add(new MoreVariableInformation(More(_offset + _maxChildren, _maxChildren)));
            }

            return(result);
        }
Exemple #5
0
 async Task <string[]> GetAllChildFormatSpecifiersAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.FormatSpecifier)
            .ToArray());
 }
Exemple #6
0
 async Task <string[]> GetAllChildNamesAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.DisplayName)
            .ToArray());
 }
Exemple #7
0
 async Task <string[]> GetChildNamesAsync(IChildAdapter childAdapter, int offset, int count)
 {
     return((await childAdapter.GetChildrenAsync(offset, count))
            .Select(child => child.DisplayName)
            .ToArray());
 }
        public async Task <IList <IVariableInformation> > GetChildrenAsync(int from, int count)
        {
            await InitAsync();

            return(await _adapter.GetChildrenAsync(from, count));
        }
        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());
        }
Exemple #10
0
 public async Task <IList <IVariableInformation> > GetChildrenAsync(int from, int count) =>
 await _childAdapter.GetChildrenAsync(from, count);