コード例 #1
0
ファイル: V85Target.cs プロジェクト: nickgaya/selenium
        /// <summary>
        /// Asynchronously gets the targets available for this session.
        /// </summary>
        /// <returns>
        /// A task that represents the asynchronous operation. The task result
        /// contains the list of <see cref="TargetInfo"/> objects describing the
        /// targets available for this session.
        /// </returns>
        public override async Task <ReadOnlyCollection <TargetInfo> > GetTargets()
        {
            List <TargetInfo> targets = new List <TargetInfo>();
            var response = await adapter.GetTargets();

            for (int i = 0; i < response.TargetInfos.Length; i++)
            {
                var targetInfo = response.TargetInfos[i];
                var mapped     = new TargetInfo()
                {
                    TargetId         = targetInfo.TargetId,
                    Title            = targetInfo.Title,
                    Type             = targetInfo.Type,
                    Url              = targetInfo.Url,
                    OpenerId         = targetInfo.OpenerId,
                    BrowserContextId = targetInfo.BrowserContextId,
                    IsAttached       = targetInfo.Attached
                };
                targets.Add(mapped);
            }

            return(targets.AsReadOnly());
        }