Custom Action Help : Custom Action : ICustomAction Interface (Deprecated) : Example

Example
The following is a simple implementation that demonstrates how to retrieve SPListItem object(s) from the passed in parameter, process the parameters, and how to notify the web parts about the outcome of the custom action.
Below is an example of a custom action class. This class verifies that if this item has high priority, it must be assigned to somebody. Otherwise, it will cancel the operation.
using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Microsoft.SharePoint;
using WA.Core;
 
namespace CustomActionSample
{
public class MyCustomAction : ICustomAction
{
public void Perform(HttpContext context, ICollection listItems, CustomActionCancelEventArgs evt)
{
if (listItems.Count == 0)
         {
        evt.Cancel = true;
        evt.Message = "There is no item to validate";
         return;
          }
          SPListItem item = null;
            IEnumerator enumerator = listItems.GetEnumerator();
             while (enumerator.MoveNext())
  {
                item = enumerator.Current as SPListItem;
                if (item != null)
                {
 if (item["Priority"] != null)
                   {
                       string priority = item["Priority"].ToString();
                       if ("(1) High".Equals(priority))
                      {
 if (item["Assigned To"] == null ||
                       string.IsNullOrEmpty(item["Assigned To"].ToString()))
}
  evt.Cancel = true;
  evt.Message = "A high priority task must be assigned to a user";
     }
                       }
                    }
                }
            }
        }
    }
}