The easiest way to tell SharePoint not to activate this
feature is to throw SPException with your message.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
string someListName = properties.Definition.Properties["ParentListName"].Value;
if (string.IsNullOrEmpty(someListName))
throw new SPException("Please supply value of 'ParentListName' property.");
SPSite site = (SPSite)properties.Feature.Parent;
SPList someList = site.RootWeb.Lists[someListName];
if (someList == null)
throw new SPException(string.Format("List:'{0}' does not exist. Please create it first before activating this feature.", someListName));
//do your stuff
}
That's it.
No comments:
Post a Comment