Table of Contents

Class PnPContextFactory

Namespace
PnP.Core.Services
Assembly
PnP.Core.dll

Public factory service to create PnPContext object instances

public class PnPContextFactory : IPnPContextFactory
Inheritance
PnPContextFactory
Implements
Inherited Members

Constructors

PnPContextFactory(ILogger<PnPContext>, SharePointRestClient, MicrosoftGraphClient, IOptions<PnPContextFactoryOptions>, IOptions<PnPGlobalSettingsOptions>, EventHub)

Default constructor for PnPContextFactory

public PnPContextFactory(ILogger<PnPContext> logger, SharePointRestClient sharePointRestClient, MicrosoftGraphClient microsoftGraphClient, IOptions<PnPContextFactoryOptions> contextOptions, IOptions<PnPGlobalSettingsOptions> globalOptions, EventHub eventHub)

Parameters

logger ILogger<PnPContext>

Connected logger

sharePointRestClient SharePointRestClient

SharePoint REST http client to use

microsoftGraphClient MicrosoftGraphClient

Microsoft Graph http client to use

contextOptions IOptions<PnPContextFactoryOptions>

PnPContextFactory options

globalOptions IOptions<PnPGlobalSettingsOptions>

Global options to use

eventHub EventHub

EventHub instance

Properties

ContextOptions

Options used to configure this PnPContext

protected PnPContextFactoryOptions ContextOptions { get; }

Property Value

PnPContextFactoryOptions

EventHub

Gets the EventHub instance, can be used to tap into events like request retry (due to throttling)

public EventHub EventHub { get; }

Property Value

EventHub

GlobalOptions

Options used to configure this PnPContext

protected PnPGlobalSettingsOptions GlobalOptions { get; }

Property Value

PnPGlobalSettingsOptions

Log

Connected logger

protected ILogger Log { get; }

Property Value

ILogger

MicrosoftGraphClient

Connected Microsoft Graph http client

protected MicrosoftGraphClient MicrosoftGraphClient { get; }

Property Value

MicrosoftGraphClient

SharePointRestClient

Connected SharePoint REST http client

protected SharePointRestClient SharePointRestClient { get; }

Property Value

SharePointRestClient

Methods

Create(Guid, IAuthenticationProvider, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and Authentication Provider instance

public virtual PnPContext Create(Guid groupId, IAuthenticationProvider authenticationProvider, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Guid, IAuthenticationProvider, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and Authentication Provider instance

public virtual PnPContext Create(Guid groupId, IAuthenticationProvider authenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Guid, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and using the default Authentication Provider

public virtual PnPContext Create(Guid groupId, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Guid, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and using the default Authentication Provider

public virtual PnPContext Create(Guid groupId, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(string, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(string name, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(string, Action<IAuthenticationProvider>, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(string name, Action<IAuthenticationProvider> initializeAuthenticationProvider, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the authentication provider

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(string, Action<IAuthenticationProvider>, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(string name, Action<IAuthenticationProvider> initializeAuthenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the authentication provider

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(string, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(string name, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Uri, IAuthenticationProvider, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(Uri url, IAuthenticationProvider authenticationProvider, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Uri, IAuthenticationProvider, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(Uri url, IAuthenticationProvider authenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Uri, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(Uri url, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

Create(Uri, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual PnPContext Create(Uri url, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

PnPContext

A PnPContext object based on the provided configuration name

CreateAsync(Guid, IAuthenticationProvider, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and Authentication Provider instance

public virtual Task<PnPContext> CreateAsync(Guid groupId, IAuthenticationProvider authenticationProvider, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Guid, IAuthenticationProvider, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and Authentication Provider instance

public virtual Task<PnPContext> CreateAsync(Guid groupId, IAuthenticationProvider authenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Guid, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and using the default Authentication Provider

public virtual Task<PnPContext> CreateAsync(Guid groupId, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Guid, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided group and using the default Authentication Provider

public virtual Task<PnPContext> CreateAsync(Guid groupId, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

groupId Guid

The id of an Microsoft 365 group

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(string, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(string name, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(string, Action<IAuthenticationProvider>, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(string name, Action<IAuthenticationProvider> initializeAuthenticationProvider, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the authentication provider

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(string, Action<IAuthenticationProvider>, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(string name, Action<IAuthenticationProvider> initializeAuthenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the authentication provider

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(string, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(string name, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

name string

The name of the PnPContext configuration to use

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Uri, IAuthenticationProvider, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(Uri url, IAuthenticationProvider authenticationProvider, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Uri, IAuthenticationProvider, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(Uri url, IAuthenticationProvider authenticationProvider, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

authenticationProvider IAuthenticationProvider

The Authentication Provider to use to authenticate within the PnPContext

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Uri, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(Uri url, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name

CreateAsync(Uri, CancellationToken, PnPContextOptions)

Creates a new instance of PnPContext based on a provided configuration name

public virtual Task<PnPContext> CreateAsync(Uri url, CancellationToken cancellationToken, PnPContextOptions options = null)

Parameters

url Uri

The URL of the PnPContext as a URI

cancellationToken CancellationToken

The cancellation token to cancel operation

options PnPContextOptions

Options used to configure the created context

Returns

Task<PnPContext>

A PnPContext object based on the provided configuration name