This post explains the new object model hierarchy in SharePoint 2010, which describes about each object in below diagram.
Create a console project in Visual Studio and write a code snippet for each object to better understand the purpose. The classes in above diagram used for administration and configuration purpose and these are used for implementing service applications.
SPFarm represents the SharePoint Server Farm, You can use the below code to list the servers in SharePoint Farm
SPServer object represents a server in SharePoint form, You can get a current reference to the SPServer object as follows
Number of services run in SharePoint platform which can include features such as web services or search services which provides search functionality to other services. SharePoint 2010 provides several services out of the box, each of these services represented by an object that derives from SPService class.
SharePoint farm can have multiple servers, each server can have more than one instance. SPServiceInstance object represents an instance of a service that is running on a particular server.
SPWebService is the parent service that hosts all the front-end web sites within a SharePoint farm.
The following classes allows you to programmatically access the sites and data contained in the sites, lists and libraries. These are the commonly used classes in SharePoint Development.
WebApplication is the topmost object in the site hierarchy, Each Web Application configured in SharePoint is represented by SPWebApplication object in object model
In SharePoint each site collection is represented by SPSite object and is very frequently used in the SharePoint Application Development. Code to create a SPSite object as below
To Display the Sites in Site Collection,
Within the object model , sites are represented by SPWeb objects. To obtain a reference to the root site in SharePoint site collection you can write the below code
SharePoint content is stored in lists or document libraries. Both lists and document libraries are represented as SPList in object model.
Each item in SharePoint list or library is represented by an SPListItem object which can be accessed via the SPList.Items collection. Listing the all master pages in site collection
SPListItem object represents only metadata for the file, To perform work on file you need to use SPFile object as shown below
|Share this post :|