Table of Contents

Interface IPnPContextFactory

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

Public interface for the injectable service to create an PnPContext

public interface IPnPContextFactory

Properties

EventHub

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

EventHub EventHub { get; }

Property Value

EventHub

Methods

Create(Guid, IAuthenticationProvider, PnPContextOptions)

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

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

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

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

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

PnPContext Create(string name, PnPContextOptions options = null)

Parameters

name string

The name of the 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 and on a custom initialization function for the IAuthenticationProvider reference instance

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

Parameters

name string

The name of the configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the context

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 and on a custom initialization function for the IAuthenticationProvider reference instance

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

Parameters

name string

The name of the configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the context

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

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

Parameters

name string

The name of the 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 URL and Authentication Provider instance

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 URL and Authentication Provider instance

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 URL and using the default Authentication Provider

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 URL and using the default Authentication Provider

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

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

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

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

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

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

Parameters

name string

The name of the 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 and on a custom initialization function for the IAuthenticationProvider reference instance

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

Parameters

name string

The name of the configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the context

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 and on a custom initialization function for the IAuthenticationProvider reference instance

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

Parameters

name string

The name of the configuration to use

initializeAuthenticationProvider Action<IAuthenticationProvider>

The function to initialize the context

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

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

Parameters

name string

The name of the 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 URL and Authentication Provider instance

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 URL and Authentication Provider instance

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 URL and using the default Authentication Provider

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 URL and using the default Authentication Provider

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