This project is read-only.

SPFeatureReceiverProperties Extension Methods

bool TryCastToSiteCollection(out SPSite sitecollection)
Tries to cast the parent of the feature to a sitecollection. A return value indicates whether it succeeded or not.

bool TryCastToSite(out SPWeb site)
Tries to cast the parent of the feature to a site (can also be rootweb). A return value indicates whether it succeeded or not.
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb site;

            if (properties.TryCastToSite(out site))
            {
                // success
            }
        }

bool TryCastToWebApplication(out SPWebApplication application)
Tries to cast the parent of the feature to a webapplication. A return value indicates whether it succeeded or not.

bool TryCastToFarm(out SPFarm farm)
Tries to cast the parent of the feature to a farm. A return value indicates whether it succeeded or not.

void UpdateModule()
Updates all file elements inside the module element, overriding the IgnoreIfAlreadyExist flag.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
  properties.UpdateModule();
}
Note: A more detailed example can be found at my blog

Last edited Feb 19, 2010 at 1:41 PM by jole, version 6

Comments

No comments yet.