public CookieListItemArgs(Cookie ck, TransformAction ta)
 {
     Cookie = ck;
     TransformAction = ta;
 }
 /// <summary>
 /// Append cookies.
 /// </summary>
 /// <param name="text"> The StringBuilder.</param>
 /// <param name="cookies"> The cookies.</param>
 public static void AppendCookies(StringBuilder text, Cookie[] cookies)
 {
     foreach ( Cookie ck in cookies )
     {
         text.AppendFormat("Name: {0}, Value: {1}, Path: {2}, Domain: {3} \r\n Port: {4}, Secure: {5}, Timestamp: {6}, Version: {7}\r\n", ck.Name,
             ck.Value, ck.Path, ck.Domain, ck.Port , ck.Secure, ck.TimeStamp, ck.Version);
     }
 }
        private void UpdateTransformAction()
        {
            CookiesTransform transform = (CookiesTransform)base.WebTransform;
            TransformAction action = null;
            Cookie cookie = null;

            switch ( this.cmbTransformAction.SelectedIndex )
            {
                case 0:
                    // Add TransformAction and cookie too.
                    AddTransformAction a = new AddTransformAction();
                    a.Name = this.txtCookieName.Text;
                    a.Value = TransformValue;
                    action = a;

                    if ( _hasDescription )
                    {
                        a.Description = txtTransformDescription.Text;// + " with an add transform action";
                    }

                    // Add dummy cookie.
                    cookie = new Cookie();
                    cookie.Domain = txtDomain.Text;
                    cookie.Name = txtCookieName.Text;
                    cookie.Path = txtPath.Text;
                    cookie.Port = txtPort.Text;
                    cookie.Expires = this.dtExpires.Value;
                    break;
                case 1:
                    // Update
                    UpdateTransformAction u = new UpdateTransformAction();
                    u.Name = this.txtCookieName.Text;
                    u.Value = TransformValue;
                    action = u;

                    if ( _hasDescription )
                    {
                        u.Description = txtTransformDescription.Text;// + " with an update transform action";
                    }
                    break;
                case 2:
                    // Remove
                    RemoveTransformAction r = new RemoveTransformAction();
                    r.Name = this.txtCookieName.Text;
                    action = r;
                    r.Description = "Removes a cookie";
                    break;
            }

            if ( _isEdit )
            {
                ListViewItem updateItem = lstActions.Items[_editIndex];
                updateItem.Text = txtCookieName.Text;
                if ( action.Description != null )
                {
                    updateItem.SubItems[1].Text = action.Description;
                }
                else
                {
                    action.Description = updateItem.SubItems[1].Text;
                }

                updateItem.Tag = new CookieListItemArgs(cookie, action);

                btnUpdate.Text = "Add";
                _isEdit = false;
            }
            else
            {
                // Add List View Item
                #region Add List View Item
                ListViewItem listItem = new ListViewItem();
                listItem.Text = txtCookieName.Text;
                listItem.SubItems.Add(action.Description);
                listItem.Tag = new CookieListItemArgs(cookie, action);
                lstActions.Items.Add(listItem);
                #endregion
            }

            this.txtCookieName.Text = String.Empty;
            this.txtDomain.Text  = String.Empty;
            this.txtPath.Text  = String.Empty;
            this.txtPort.Text  = String.Empty;
            this.txtTransformDescription.Text  = String.Empty;
        }
 /// <summary>
 /// Adds a cookie.
 /// </summary>
 /// <param name="cookie"> The cookie to add.</param>
 public void AddCookie(Cookie cookie)
 {
     _cookies.Add(cookie);
 }