Example #1
0
        internal PnPContext(ILogger logger,
                            IAuthenticationProvider authenticationProvider,
                            SharePointRestClient sharePointRestClient,
                            MicrosoftGraphClient microsoftGraphClient,
                            PnPContextFactoryOptions contextOptions,
                            PnPGlobalSettingsOptions globalOptions,
                            TelemetryManager telemetryManager)
        {
            Id     = Guid.NewGuid();
            Logger = logger;

#if DEBUG
            Mode = TestMode.Default;
#endif
            AuthenticationProvider = authenticationProvider;
            RestClient             = sharePointRestClient;
            GraphClient            = microsoftGraphClient;
            this.GlobalOptions     = globalOptions;
            this.ContextOptions    = contextOptions;
            telemetry = telemetryManager;

            if (this.ContextOptions != null)
            {
                GraphFirst         = this.ContextOptions.GraphFirst;
                GraphAlwaysUseBeta = this.ContextOptions.GraphAlwaysUseBeta;
                GraphCanUseBeta    = this.ContextOptions.GraphCanUseBeta;
            }

            BatchClient = new BatchClient(this, this.GlobalOptions, telemetryManager);
        }
Example #2
0
 internal PnPContext(ILogger logger,
                     IAuthenticationProvider authenticationProvider,
                     SharePointRestClient sharePointRestClient,
                     MicrosoftGraphClient microsoftGraphClient,
                     IOptions <PnPContextFactoryOptions> contextOptions,
                     IOptions <PnPGlobalSettingsOptions> globalOptions,
                     TelemetryManager telemetryManager) :
     this(logger,
          authenticationProvider,
          sharePointRestClient,
          microsoftGraphClient,
          contextOptions?.Value,
          globalOptions?.Value,
          telemetryManager)
 {
 }
Example #3
0
        /// <summary>
        /// Default constructor for <see cref="PnPContextFactory"/>
        /// </summary>
        /// <param name="logger">Connected logger</param>
        /// <param name="sharePointRestClient">SharePoint REST http client to use</param>
        /// <param name="microsoftGraphClient">Microsoft Graph http client to use</param>
        /// <param name="contextOptions"><see cref="PnPContextFactory"/> options</param>
        /// <param name="globalOptions">Global options to use</param>
        public PnPContextFactory(
            ILogger <PnPContext> logger,
            SharePointRestClient sharePointRestClient,
            MicrosoftGraphClient microsoftGraphClient,
            IOptions <PnPContextFactoryOptions> contextOptions,
            IOptions <PnPGlobalSettingsOptions> globalOptions)
        {
            // Store logger and options locally
            Log = logger;
            SharePointRestClient = sharePointRestClient;
            MicrosoftGraphClient = microsoftGraphClient;
            ContextOptions       = contextOptions?.Value;
            GlobalOptions        = globalOptions?.Value;

            ConnectTelemetry();
        }
Example #4
0
        internal PnPContext(ILogger logger,
                            IAuthenticationProvider authenticationProvider,
                            SharePointRestClient sharePointRestClient,
                            MicrosoftGraphClient microsoftGraphClient,
                            PnPContextFactoryOptions contextOptions,
                            PnPGlobalSettingsOptions globalOptions,
                            TelemetryManager telemetryManager)
        {
            Id     = Guid.NewGuid();
            Logger = logger;

#if DEBUG
            Mode = TestMode.Default;
#endif
            AuthenticationProvider = authenticationProvider;
            RestClient             = sharePointRestClient;
            GraphClient            = microsoftGraphClient;
            GlobalOptions          = globalOptions;
            ContextOptions         = contextOptions;
            telemetry = telemetryManager;

            if (ContextOptions != null)
            {
                GraphFirst         = ContextOptions.GraphFirst;
                GraphAlwaysUseBeta = ContextOptions.GraphAlwaysUseBeta;
                GraphCanUseBeta    = ContextOptions.GraphCanUseBeta;
            }

            if (globalOptions != null && globalOptions.Environment.HasValue)
            {
                Environment = globalOptions.Environment.Value;
                // Ensure the Microsoft Graph URL is set depending on the used cloud environment
                GraphClient.UpdateBaseAddress(CloudManager.GetMicrosoftGraphAuthority(Environment.Value));
            }

            BatchClient = new BatchClient(this, GlobalOptions, telemetryManager);
        }