Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="options">The <see cref="CommunityGraphClientOptions"/> to use.</param>
        /// <param name="messageLogger">An <see cref="IHttpMessageLogger"/> instance to insert into the Http pipeline.</param>
        /// <param name="authenticationProvider">The <see cref="IAuthenticationProvider"/> to authenticate requests.</param>
        /// <param name="version">The graph version to use.</param>
        /// <param name="nationalCloud">The national cloud endpoint to use.</param>
        /// <param name="proxy">The proxy to be used with created client.</param>
        /// <param name="finalHandler">The last HttpMessageHandler to HTTP calls.
        /// The default implementation creates a new instance of <see cref="HttpClientHandler"/> for each HttpClient.</param>
        /// <returns>A GraphServiceClient instance with the SharePoint handler configured.</returns>
        public static GraphServiceClient Create(CommunityGraphClientOptions options, IHttpMessageLogger messageLogger, IAuthenticationProvider authenticationProvider, string version = "v1.0", string nationalCloud = "Global", IWebProxy proxy = null, HttpMessageHandler finalHandler = null)
        {
            LoggingMessageHandler loggingHandler = new LoggingMessageHandler(messageLogger);

            var handlers = GraphClientFactory.CreateDefaultHandlers(authenticationProvider);

            var compressionHandlerIndex = handlers.ToList().FindIndex(h => h is CompressionHandler);

            if (compressionHandlerIndex > -1)
            {
                handlers.Insert(compressionHandlerIndex, loggingHandler);
            }
            else
            {
                handlers.Add(loggingHandler);
            }

            if (options.DisableTelemetry != true)
            {
                LogFactoryMethod(authenticationProvider.GetType().Name, true);
            }

            return(Create(options, handlers, version, nationalCloud, proxy, finalHandler));
        }
Exemplo n.º 2
0
 public LoggingMessageHandler(IHttpMessageLogger logger, HttpMessageHandler innerHandler = null)
 {
     InnerHandler = innerHandler ?? new HttpClientHandler();
     this.logger  = logger ?? new NullHttpMessageLogger();
 }
Exemplo n.º 3
0
 public LoggingHandler(IHttpMessageLogger logger)
 {
     _logger         = logger;
     StoreExchangeId = true;
 }