示例#1
0
        private bool TryGetNext(out CapturedGuiOperation operation)
        {
            lock (_syncpoint)
            {
                if (_captured.Count > 0)
                {
                    operation = _captured.Dequeue();
                    return(true);
                }
            }

            operation = default(CapturedGuiOperation);
            return(false);
        }
示例#2
0
        private void Capture(bool success, DialogViewModel viewModel)
        {
            var capture = default(CapturedGuiOperation);

            switch (viewModel)
            {
            case CredentialsViewModel cvm:
            {
                capture = new CapturedGuiOperation
                {
                    Output = new CapturedGuiOutput
                    {
                        Login    = cvm.Login,
                        IsValid  = viewModel.IsValid,
                        Password = cvm.Password,
                        Result   = (int)viewModel.Result,
                        Success  = success,
                    },
                    DialogType = cvm.GetType().FullName,
                };
            }
            break;

            case OAuthViewModel oavm:
            {
                capture = new CapturedGuiOperation
                {
                    Output = new CapturedGuiOutput
                    {
                        IsValid = viewModel.IsValid,
                        Result  = (int)viewModel.Result,
                        Success = success,
                    },
                    DialogType = oavm.GetType().FullName,
                };
            }
            break;

            default:
                throw new ReplayDataException($"Unknown type `{viewModel.GetType().FullName}`");
            }

            lock (_syncpoint)
            {
                _captured.Enqueue(capture);
            }
        }
示例#3
0
        internal bool GetCapturedData(ICapturedDataFilter filter, out CapturedGuiData capturedData)
        {
            if (filter is null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            lock (_syncpoint)
            {
                capturedData = new CapturedGuiData
                {
                    Operations = new List <CapturedGuiOperation>(_captured.Count),
                };

                foreach (var item in _captured)
                {
                    var operation = new CapturedGuiOperation
                    {
                        Output = new CapturedGuiOutput
                        {
                            IsValid = item.Output.IsValid,
                            Login   = item.Output.Login != null
                                ? FauxUsername
                                : null,
                            Password = item.Output.Password != null
                                ? FauxPassword
                                : null,
                            Result  = item.Output.Result,
                            Success = item.Output.Success,
                        },
                        DialogType = item.DialogType,
                    };

                    capturedData.Operations.Add(operation);
                }
            }

            return(true);
        }