Comments on: (SPWeb)properties.Feature.Parent no more … a handy Feature Receiver Base Class http://trentacular.com/2009/04/base-feature-receiver/ Trent Foley's Spectacular Technical Blog Fri, 18 May 2012 14:01:04 +0000 hourly 1 http://wordpress.org/?v=3.3.2 By: Juan http://trentacular.com/2009/04/base-feature-receiver/comment-page-1/#comment-2332 Juan Thu, 01 Dec 2011 05:02:55 +0000 http://trentacular.com/?p=104#comment-2332 Interesting, I think it's a bit of overkill, but it might have some other useful applications. I use Lambda functions, and extensions methods for Disposing of SPWeb and SPSite, and also disposing memory leans on traversals of objects. Some might say that is overkill too. Interesting, I think it’s a bit of overkill, but it might have some other useful applications. I use Lambda functions, and extensions methods for Disposing of SPWeb and SPSite, and also disposing memory leans on traversals of objects. Some might say that is overkill too.

]]>
By: Ry http://trentacular.com/2009/04/base-feature-receiver/comment-page-1/#comment-1013 Ry Thu, 21 Jan 2010 09:45:26 +0000 http://trentacular.com/?p=104#comment-1013 Lovely :D thanks a million. Lovely :D thanks a million.

]]>
By: Trent http://trentacular.com/2009/04/base-feature-receiver/comment-page-1/#comment-790 Trent Mon, 26 Oct 2009 15:07:45 +0000 http://trentacular.com/?p=104#comment-790 @Juozas Using the generic restraint would work only for the Web and Site scopes. The SPWebApplication and SPFarm objects do not implement IDisposable. Also, it is <strong>not</strong> necessary to dispose the SPWeb or SPSite object referenced by properties.Feature.Parent. See the following links for more details: http://solutionizing.net/2009/02/08/do-not-dispose-spfeaturereceiverproperties-feature-parent/ http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/c0f1a05f-f1db-4f37-8f24-5966ab43e73b/ @Juozas

Using the generic restraint would work only for the Web and Site scopes. The SPWebApplication and SPFarm objects do not implement IDisposable.

Also, it is not necessary to dispose the SPWeb or SPSite object referenced by properties.Feature.Parent. See the following links for more details:
http://solutionizing.net/2009/02/08/do-not-dispose-spfeaturereceiverproperties-feature-parent/
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/c0f1a05f-f1db-4f37-8f24-5966ab43e73b/

]]>
By: Juozas http://trentacular.com/2009/04/base-feature-receiver/comment-page-1/#comment-788 Juozas Mon, 26 Oct 2009 09:43:42 +0000 http://trentacular.com/?p=104#comment-788 I think you can improve BaseFeatureReceiver by adding a generic argument restriction: class BaseFeatureReceiver : SPFeatureReceiver where T : IDisposable Then you could implement FeatureActivated and FeatureDeactivating a little better: public sealed override void FeatureActivated(SPFeatureReceiverProperties properties) { using (T parent = (T)properties.Feature.Parent) { FeatureActivated(parent, properties); } } I think you can improve BaseFeatureReceiver by adding a generic argument restriction:

class BaseFeatureReceiver : SPFeatureReceiver where T : IDisposable

Then you could implement FeatureActivated and FeatureDeactivating a little better:

public sealed override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (T parent = (T)properties.Feature.Parent)
{
FeatureActivated(parent, properties);
}
}

]]>