C# Class Microsoft.SharePoint.Client.WebExtensions

Class that deals with site (both site collection and web site) creation, status, retrieval and settings
Datei anzeigen Open project: OfficeDev/PnP-Sites-Core

Public Methods

Method Description
AddIndexedPropertyBagKey ( this web, string key ) : bool

Marks a property bag key for indexing

AddRemoteEventReceiver ( this web, string name, string url, EventReceiverType eventReceiverType, EventReceiverSynchronization synchronization, bool force ) : EventReceiverDefinition

Registers a remote event receiver

AddRemoteEventReceiver ( this web, string name, string url, EventReceiverType eventReceiverType, EventReceiverSynchronization synchronization, int sequenceNumber, bool force ) : EventReceiverDefinition

Registers a remote event receiver

ApplyProvisioningTemplate ( this web, OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate template, OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ProvisioningTemplateApplyingInformation applyingInformation = null ) : void

Can be used to apply custom remote provisioning template on top of existing site.

CreateWeb ( this parentWeb, OfficeDevPnP.Core.Entities.SiteEntity subsite, bool inheritPermissions = true, bool inheritNavigation = true ) : Web

Adds a new child Web (site) to a parent Web.

CreateWeb ( this parentWeb, string title, string leafUrl, string description, string template, int language, bool inheritPermissions = true, bool inheritNavigation = true ) : Web

Adds a new child Web (site) to a parent Web.

DisableRequestAccess ( this web ) : void

Disables the request access on the web.

EnableRequestAccess ( this web ) : void

Enables request access for the specified e-mail addresses.

EnableRequestAccess ( this web, IEnumerable emails ) : void

Enables request access for the specified e-mail addresses.

GetAllWebUrls ( this site ) : IEnumerable

Gets the collection of the URLs of all Web sites that are contained within the site collection, including the top-level site and its subsites.

This is analagous to the SPSite.AllWebs property and can be used to get a collection of all web site URLs to loop through, e.g. for branding.

GetAppInstances ( this web ) : ClientObjectList

Returns all app instances

GetBaseTemplateId ( this parentWeb ) : String

Returns the Base Template ID for the current web

GetEventReceiverById ( this web, Guid id ) : EventReceiverDefinition

Returns an event receiver definition

GetEventReceiverByName ( this web, string name ) : EventReceiverDefinition

Returns an event receiver definition

GetIndexedPropertyBagKeys ( this web ) : IEnumerable

Returns all keys in the property bag that have been marked for indexing

GetPropertyBagValueDateTime ( this web, string key, DateTime defaultValue ) : DateTime?

Get DateTime typed property bag value. If does not contain, returns default value.

GetPropertyBagValueInt ( this web, string key, int defaultValue ) : int?

Get int typed property bag value. If does not contain, returns default value.

GetPropertyBagValueString ( this web, string key, string defaultValue ) : string

Get string typed property bag value. If does not contain, returns given default value.

GetProvisioningTemplate ( this web ) : ProvisioningTemplate

Can be used to extract custom provisioning template from existing site. The extracted template will be compared with the default base template.

GetProvisioningTemplate ( this web, ProvisioningTemplateCreationInformation creationInfo ) : ProvisioningTemplate

Can be used to extract custom provisioning template from existing site. The extracted template will be compared with the default base template.

GetRequestAccessEmails ( this web ) : IEnumerable

Gets the request access e-mail addresses of the web.

GetWeb ( this parentWeb, string leafUrl ) : Web

Returns the child Web site with the specified leaf URL.

The ServerRelativeUrl property of the retrieved Web is instantiated.

IsNoScriptSite ( this site ) : bool

Detects if the site in question has no script enabled or not. Detection is done by verifying if the AddAndCustomizePages permission is missing. See https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f for the effects of NoScript

IsPublishingWeb ( this web ) : bool
IsSubSite ( this web ) : bool

Checks if the current web is a sub site or not

PropertyBagContainsKey ( this web, string key ) : bool

Checks if the given property bag entry exists

ReIndexWeb ( this web ) : void

Queues a web for a full crawl the next incremental crawl

RemoveIndexedPropertyBagKey ( this web, string key ) : bool

Unmarks a property bag key for indexing

RemovePropertyBagValue ( this web, string key ) : void

Removes a property bag value from the property bag

SetLocalizationLabels ( this web, string cultureName, string titleResource, string descriptionResource ) : void

Can be used to set translations for different cultures.

SetPageOutputCache ( this web, bool enableOutputCache, int anonymousCacheProfileId, int authenticatedCacheProfileId, bool debugCacheInformation ) : void

Sets output cache on publishing web. The settings can be maintained from UI by visiting url /_layouts/15/sitecachesettings.aspx

SetPropertyBagValue ( this web, string key, DateTime value ) : void

Sets a key/value pair in the web property bag

SetPropertyBagValue ( this web, string key, int value ) : void

Sets a key/value pair in the web property bag

SetPropertyBagValue ( this web, string key, string value ) : void

Sets a key/value pair in the web property bag

SiteSearch ( this web ) : List

Returns all site collections that are indexed. In MT the search center, mysite host and contenttype hub are defined as non indexable by default and thus are not returned

SiteSearchScopedByTitle ( this web, string siteTitle ) : List

Returns all site collection that match with the provided title

SiteSearchScopedByUrl ( this web, string siteUrl ) : List

Returns all site collection that start with the provided URL

UninstallSolution ( this site, Guid packageGuid, string fileName, int majorVersion = 1, int minorVersion ) : void

Uninstalls a sandbox solution package (.WSP) file

WebExists ( this parentWeb, string leafUrl ) : bool

Determines if a child Web site with the specified leaf URL exists.

WebExistsByTitle ( this parentWeb, string title ) : bool

Determines if a web exists by title.

WebExistsFullUrl ( this context, string webFullUrl ) : bool

Determines if a Web (site) exists at the specified full URL, either accessible or that returns an access error.

Private Methods

Method Description
DeleteWeb ( this parentWeb, string leafUrl ) : bool
GetEncodedValueForSearchIndexProperty ( IEnumerable keys ) : string

Used to convert the list of property keys is required format for listing keys to be index

GetPropertyBagValueInternal ( Web web, string key ) : object

Type independent implementation of the property getter.

InstallSolution ( this site, Guid packageGuid, string sourceFilePath, int majorVersion = 1, int minorVersion ) : void
IsCannotGetSiteException ( Exception ex ) : bool
IsUnableToAccessSiteException ( Exception ex ) : bool
MySiteSearch ( this web ) : List
ProcessQuery ( this web, string keywordQueryValue, List sites, KeywordQuery keywordQuery, int startRow ) : int

Runs a query

RemoveAppInstanceByTitle ( this web, string appTitle ) : bool
RemovePropertyBagValueInternal ( Web web, string key, bool checkIndexed ) : void

Removes a property bag value

SetPropertyBagValueInternal ( Web web, string key, object value ) : void

Sets a key/value pair in the web property bag

SiteSearch ( this web, string keywordQueryValue, bool trimDublicates = true ) : List

Method Details

AddIndexedPropertyBagKey() public static method

Marks a property bag key for indexing
public static AddIndexedPropertyBagKey ( this web, string key ) : bool
web this The web to process
key string The key to mark for indexing
return bool

AddRemoteEventReceiver() public static method

Registers a remote event receiver
public static AddRemoteEventReceiver ( this web, string name, string url, EventReceiverType eventReceiverType, EventReceiverSynchronization synchronization, bool force ) : EventReceiverDefinition
web this The web to process
name string The name of the event receiver (needs to be unique among the event receivers registered on this list)
url string The URL of the remote WCF service that handles the event
eventReceiverType EventReceiverType
synchronization EventReceiverSynchronization
force bool If True any event already registered with the same name will be removed first.
return EventReceiverDefinition

AddRemoteEventReceiver() public static method

Registers a remote event receiver
public static AddRemoteEventReceiver ( this web, string name, string url, EventReceiverType eventReceiverType, EventReceiverSynchronization synchronization, int sequenceNumber, bool force ) : EventReceiverDefinition
web this The web to process
name string The name of the event receiver (needs to be unique among the event receivers registered on this list)
url string The URL of the remote WCF service that handles the event
eventReceiverType EventReceiverType
synchronization EventReceiverSynchronization
sequenceNumber int
force bool If True any event already registered with the same name will be removed first.
return EventReceiverDefinition

ApplyProvisioningTemplate() public static method

Can be used to apply custom remote provisioning template on top of existing site.
public static ApplyProvisioningTemplate ( this web, OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate template, OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ProvisioningTemplateApplyingInformation applyingInformation = null ) : void
web this
template OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate ProvisioningTemplate with the settings to be applied
applyingInformation OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ProvisioningTemplateApplyingInformation Specified additional settings and or properties
return void

CreateWeb() public static method

Adds a new child Web (site) to a parent Web.
public static CreateWeb ( this parentWeb, OfficeDevPnP.Core.Entities.SiteEntity subsite, bool inheritPermissions = true, bool inheritNavigation = true ) : Web
parentWeb this The parent Web (site) to create under
subsite OfficeDevPnP.Core.Entities.SiteEntity Details of the Web (site) to add. Only Title, Url (as the leaf URL), Description, Template and Language are used.
inheritPermissions bool Specifies whether the new site will inherit permissions from its parent site.
inheritNavigation bool Specifies whether the site inherits navigation.
return Web

CreateWeb() public static method

Adds a new child Web (site) to a parent Web.
public static CreateWeb ( this parentWeb, string title, string leafUrl, string description, string template, int language, bool inheritPermissions = true, bool inheritNavigation = true ) : Web
parentWeb this The parent Web (site) to create under
title string The title of the new site.
leafUrl string A string that represents the URL leaf name.
description string The description of the new site.
template string The name of the site template to be used for creating the new site.
language int The locale ID that specifies the language of the new site.
inheritPermissions bool Specifies whether the new site will inherit permissions from its parent site.
inheritNavigation bool Specifies whether the site inherits navigation.
return Web

DisableRequestAccess() public static method

Disables the request access on the web.
public static DisableRequestAccess ( this web ) : void
web this The web to disable request access.
return void

EnableRequestAccess() public static method

Enables request access for the specified e-mail addresses.
public static EnableRequestAccess ( this web ) : void
web this The web to enable request access.
return void

EnableRequestAccess() public static method

Enables request access for the specified e-mail addresses.
public static EnableRequestAccess ( this web, IEnumerable emails ) : void
web this The web to enable request access.
emails IEnumerable The e-mail addresses to send access requests to.
return void

GetAllWebUrls() public static method

Gets the collection of the URLs of all Web sites that are contained within the site collection, including the top-level site and its subsites.

This is analagous to the SPSite.AllWebs property and can be used to get a collection of all web site URLs to loop through, e.g. for branding.

public static GetAllWebUrls ( this site ) : IEnumerable
site this Site collection to retrieve the URLs for.
return IEnumerable

GetAppInstances() public static method

Returns all app instances
public static GetAppInstances ( this web ) : ClientObjectList
web this The site to process
return ClientObjectList

GetBaseTemplateId() public static method

Returns the Base Template ID for the current web
public static GetBaseTemplateId ( this parentWeb ) : String
parentWeb this The parent Web (site) to get the base template from
return String

GetEventReceiverById() public static method

Returns an event receiver definition
public static GetEventReceiverById ( this web, Guid id ) : EventReceiverDefinition
web this Web to process
id Guid
return EventReceiverDefinition

GetEventReceiverByName() public static method

Returns an event receiver definition
public static GetEventReceiverByName ( this web, string name ) : EventReceiverDefinition
web this
name string
return EventReceiverDefinition

GetIndexedPropertyBagKeys() public static method

Returns all keys in the property bag that have been marked for indexing
public static GetIndexedPropertyBagKeys ( this web ) : IEnumerable
web this The site to process
return IEnumerable

GetPropertyBagValueDateTime() public static method

Get DateTime typed property bag value. If does not contain, returns default value.
public static GetPropertyBagValueDateTime ( this web, string key, DateTime defaultValue ) : DateTime?
web this Web to read the property bag value from
key string Key of the property bag entry to return
defaultValue DateTime
return DateTime?

GetPropertyBagValueInt() public static method

Get int typed property bag value. If does not contain, returns default value.
public static GetPropertyBagValueInt ( this web, string key, int defaultValue ) : int?
web this Web to read the property bag value from
key string Key of the property bag entry to return
defaultValue int
return int?

GetPropertyBagValueString() public static method

Get string typed property bag value. If does not contain, returns given default value.
public static GetPropertyBagValueString ( this web, string key, string defaultValue ) : string
web this Web to read the property bag value from
key string Key of the property bag entry to return
defaultValue string
return string

GetProvisioningTemplate() public static method

Can be used to extract custom provisioning template from existing site. The extracted template will be compared with the default base template.
public static GetProvisioningTemplate ( this web ) : ProvisioningTemplate
web this Web to get template from
return ProvisioningTemplate

GetProvisioningTemplate() public static method

Can be used to extract custom provisioning template from existing site. The extracted template will be compared with the default base template.
public static GetProvisioningTemplate ( this web, ProvisioningTemplateCreationInformation creationInfo ) : ProvisioningTemplate
web this Web to get template from
creationInfo ProvisioningTemplateCreationInformation Specifies additional settings and/or properties
return ProvisioningTemplate

GetRequestAccessEmails() public static method

Gets the request access e-mail addresses of the web.
public static GetRequestAccessEmails ( this web ) : IEnumerable
web this The web to get the request access e-mail addresses from.
return IEnumerable

GetWeb() public static method

Returns the child Web site with the specified leaf URL.

The ServerRelativeUrl property of the retrieved Web is instantiated.

public static GetWeb ( this parentWeb, string leafUrl ) : Web
parentWeb this The Web site to check under
leafUrl string A string that represents the URL leaf name.
return Web

IsNoScriptSite() public static method

Detects if the site in question has no script enabled or not. Detection is done by verifying if the AddAndCustomizePages permission is missing. See https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f for the effects of NoScript
public static IsNoScriptSite ( this site ) : bool
site this site to verify
return bool

IsPublishingWeb() public static method

public static IsPublishingWeb ( this web ) : bool
web this
return bool

IsSubSite() public static method

Checks if the current web is a sub site or not
public static IsSubSite ( this web ) : bool
web this Web to check
return bool

PropertyBagContainsKey() public static method

Checks if the given property bag entry exists
public static PropertyBagContainsKey ( this web, string key ) : bool
web this Site to be processed - can be root web or sub site
key string Key of the property bag entry to check
return bool

ReIndexWeb() public static method

Queues a web for a full crawl the next incremental crawl
public static ReIndexWeb ( this web ) : void
web this Site to be processed
return void

RemoveIndexedPropertyBagKey() public static method

Unmarks a property bag key for indexing
public static RemoveIndexedPropertyBagKey ( this web, string key ) : bool
web this The site to process
key string The key to unmark for indexed. Case-sensitive
return bool

RemovePropertyBagValue() public static method

Removes a property bag value from the property bag
public static RemovePropertyBagValue ( this web, string key ) : void
web this The site to process
key string The key to remove
return void

SetLocalizationLabels() public static method

Can be used to set translations for different cultures.
public static SetLocalizationLabels ( this web, string cultureName, string titleResource, string descriptionResource ) : void
web this Site to be processed - can be root web or sub site
cultureName string Culture name like en-us or fi-fi
titleResource string Localized Title string
descriptionResource string Localized Description string
return void

SetPageOutputCache() public static method

Sets output cache on publishing web. The settings can be maintained from UI by visiting url /_layouts/15/sitecachesettings.aspx
public static SetPageOutputCache ( this web, bool enableOutputCache, int anonymousCacheProfileId, int authenticatedCacheProfileId, bool debugCacheInformation ) : void
web this SharePoint web
enableOutputCache bool Specify true to enable output cache. False otherwise.
anonymousCacheProfileId int Applies for anonymous users access for a site in Site Collection. Id of the profile specified in "Cache Profiles" list.
authenticatedCacheProfileId int Applies for authenticated users access for a site in the Site Collection. Id of the profile specified in "Cache Profiles" list.
debugCacheInformation bool Specify true to enable the display of additional cache information on pages in this site collection. False otherwise.
return void

SetPropertyBagValue() public static method

Sets a key/value pair in the web property bag
public static SetPropertyBagValue ( this web, string key, DateTime value ) : void
web this Web that will hold the property bag entry
key string Key for the property bag entry
value DateTime Datetime value for the property bag entry
return void

SetPropertyBagValue() public static method

Sets a key/value pair in the web property bag
public static SetPropertyBagValue ( this web, string key, int value ) : void
web this Web that will hold the property bag entry
key string Key for the property bag entry
value int Integer value for the property bag entry
return void

SetPropertyBagValue() public static method

Sets a key/value pair in the web property bag
public static SetPropertyBagValue ( this web, string key, string value ) : void
web this Web that will hold the property bag entry
key string Key for the property bag entry
value string String value for the property bag entry
return void

SiteSearch() public static method

Returns all site collections that are indexed. In MT the search center, mysite host and contenttype hub are defined as non indexable by default and thus are not returned
public static SiteSearch ( this web ) : List
web this Site to be processed - can be root web or sub site
return List

SiteSearchScopedByTitle() public static method

Returns all site collection that match with the provided title
public static SiteSearchScopedByTitle ( this web, string siteTitle ) : List
web this Site to be processed - can be root web or sub site
siteTitle string Title of the site to search for
return List

SiteSearchScopedByUrl() public static method

Returns all site collection that start with the provided URL
public static SiteSearchScopedByUrl ( this web, string siteUrl ) : List
web this Site to be processed - can be root web or sub site
siteUrl string Base URL for which sites can be returned
return List

UninstallSolution() public static method

Uninstalls a sandbox solution package (.WSP) file
public static UninstallSolution ( this site, Guid packageGuid, string fileName, int majorVersion = 1, int minorVersion ) : void
site this Site collection to install to
packageGuid Guid ID of the solution, from the solution manifest
fileName string filename of the WSP file to uninstall
majorVersion int Optional major version of the solution, defaults to 1
minorVersion int Optional minor version of the solution, defaults to 0
return void

WebExists() public static method

Determines if a child Web site with the specified leaf URL exists.
public static WebExists ( this parentWeb, string leafUrl ) : bool
parentWeb this The Web site to check under
leafUrl string A string that represents the URL leaf name.
return bool

WebExistsByTitle() public static method

Determines if a web exists by title.
public static WebExistsByTitle ( this parentWeb, string title ) : bool
parentWeb this Parent web to check under.
title string Title of the web to check.
return bool

WebExistsFullUrl() public static method

Determines if a Web (site) exists at the specified full URL, either accessible or that returns an access error.
public static WebExistsFullUrl ( this context, string webFullUrl ) : bool
context this Existing context, used to provide credentials.
webFullUrl string Full URL of the site to check.
return bool