Add to My Yahoo! | Google Reader or Homepage | Add to Windows Live | Add to Windows Live Alerts

Wictor Wilén

Microsoft Certified Master (MCM) - SharePoint 2010 | Microsoft Most Valuable Professional (MVP) - SharePoint Server MVP | Author

Four interesting changes to the SharePoint Foundation 2010 API

Posted at 2009-12-13 12:40 by Wictor Wilén in SharePoint 2010 with 9 comments.

Working with SharePoint 2010 is really a joy, you stumble upon great things all the time. The API has not had any revolutionary changes to be backwards compatible; but small changes here and there, both publically visible and internally, really makes the API better than before.

SPListItem.SPContentTypeId

To get the Content Type Id of an SPListItem you had to first get the SPContentType from the SPListItem.ContentType and then get the Id of the content type. This method was one marked as internal in version 12, but is now marked 14. It’s those little things. There are actually a lot of previously internal properties and methods that now are public, for example the CanBeDisplayedInEditForm property on the SPField class.

SPListCollection.TryGetList(string listTitle)

Last year I wrote a post about this one and now it’s there. No need to encapsulate your code with try-catch blocks when trying to get a list using it’s name. TryGetList will return null if the list does not exist. Thank you guys, up there in Redmond!

SPWebPartManager disposes the SPWeb object

One change that is really great. When using the SPWebPartManager or the SPLimitedWebPartManager you previously had to manually dispose the SPWeb object before disposing the Web Part manager, now that’s done when disposing the SPWebPartManager or the SPLimitedWebPartManager. This will save a lot of people a lot of memory leaks.

SPField.ListFieldUsedIn(…)

This is an interesting one, using this method you can find out which sites and lists a specific field is used. The method returns a collection of SPFieldTemplateUsage objects, which contains Guids of the list and site Id’s. One thing that also is interesting with this one is the usage of the templated ICollection instead of an array or custom collection.

There are of course a lot more, but these four I did find during my excavations this weekend. Have you found any favorite change except the obvious ones?

Comments and trackbacks

#  Social comments and analytics for this post by Trackback
Screenshot from websnpr This post was mentioned on Twitter by wictor: Just blogged: Four interesting changes to the SharePoint Foundation 2010 API http://bit.ly/74WY1H
#  Windows 7 Less Secure than Vista; Game Over for Microsoft on Consumer Front; Microsoft's Challenges in 2010 by Trackback
Screenshot from websnpr Top News Stories Microsoft's 4 Challenges in 2010 (PC World) When you're a technology mongrel
#  Try... pattern by Brian Bedard
Screenshot from websnpr I would hope they employed this method on all the SP objects. I wrote so much wrapper code just to enumerate and check and return for existence. Maybe I can throw it all away now :)
#  @Brian by Wictor
Screenshot from websnpr Totally agrees!
#  RESTful/WOA by Liz
Screenshot from websnpr If you think the SharePoint 2010 API is a joy you need to look at the MindTouch API http://developer.mindtouch.com/index.php?title=Deki/API_Reference . I've been building on this for the last couple years and the ease to extend and develop is a joy. This is a great alt to SharePoint and is also a great way to extend SharePoint. Check out: www.mindtouch.com
#  turbo by turbo
Screenshot from websnpr TurboFire is a High Intensity Interval Training or "H.I.I.T" dedicated to get people in the best shape of there life in just 12 short weeks.The best way to lose weight is to be active and follow a healthy regime. No crash diet will help you lose weight or maintain it that way. Turbo Fire workout will help you realize it. Turbo Fire sale!
#  Nice by Ryan Reynolds
Screenshot from websnpr Last year I wrote a post about this one and now it’s there. No need to encapsulate your code with try-catch blocks when trying to get a list using it’s name. TryGetList will return null if the list does not exist. Thank you guys, up there in Redmond!
#  Nice by finding an adult for dating
Screenshot from websnpr Working with SharePoint 2010 is really a joy, you stumble upon great things all the time. The API has not had any revolutionary changes to be backwards compatible; but small changes here and there, both publically visible and internally, really makes the API better than before.
#  NIce by date black singles
Screenshot from websnpr Working with SharePoint 2010 is really a joy, you stumble upon great things all the time. The API has not had any revolutionary changes to be backwards compatible; but small changes here and there, both publically visible and internally, really makes the API better than before.
Make a comment on this post:
Subject:  

Your name:  
Your Url:  
Note: submissions may have to be approved before being visible, so don't submit your comment multiple times.