public NamedPipeNotificationReplayRecord(NamedPipeReplayRecord record)
 {
     MustDispatch   = record.MustDispatch;
     Totp           = record.Totp;
     ReplayLevel    = record.ReplayLevel;
     UserIPAdress   = record.UserIPAdress;
     UserLogon      = record.UserLogon;
     UserName       = record.UserName;
     DeliveryWindow = record.DeliveryWindow;
 }
        /// <summary>
        /// DoCheckForReplay method implementation
        /// </summary>
        public bool DoCheckForReplay(NamedPipeReplayRecord requestor)
        {
            try
            {
                if (OnDecrypt == null)
                {
                    OnDecrypt += PipeClientOnDecrypt;
                }
                if (OnEncrypt == null)
                {
                    OnEncrypt += PipeClientOnEncrypt;
                }

                Task <bool> task = null;

                NamedPipeClientStream ClientStream = new NamedPipeClientStream(_servers[0], "adfsmfaconfig", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation);
                task = Task <bool> .Factory.StartNew(() =>
                {
                    try
                    {
                        ClientStream.Connect();
                        PipeStreamData ss = new PipeStreamData(ClientStream);
                        ss.WriteString(OnEncrypt(Proofkey));
                        if (OnDecrypt(ss.ReadString()) == Proofkey)
                        {
                            NamedPipeNotificationReplayRecord xdata = new NamedPipeNotificationReplayRecord(requestor);
                            ss.WriteData(ObjectToByteArray(xdata));
                            return(ByteArrayToObject <bool>(ss.ReadData()));
                        }
                    }
                    catch (IOException e)
                    {
                        LogForSlots.WriteEntry("PipeClient Error : " + e.Message, EventLogEntryType.Error, 8888);
                        ClientStream.Close();
                    }
                    finally
                    {
                        ClientStream.Close();
                    }
                    return(false);
                });

                task.Wait();
                return(task.Result);
            }
            catch (Exception e)
            {
                LogForSlots.WriteEntry("PipeClient Error : " + e.Message, EventLogEntryType.Error, 8888);
                return(false);
            }
        }