internal ServiceBundle(
     IHttpClientFactory httpClientFactory = null,
     IHttpManager httpManager             = null,
     ITelemetryReceiver telemetryReceiver = null,
     IValidatedAuthoritiesCache validatedAuthoritiesCache = null,
     IAadInstanceDiscovery aadInstanceDiscovery           = null,
     IWsTrustWebRequestManager wsTrustWebRequestManager   = null,
     bool shouldClearCaches = false)
 {
     HttpManager               = httpManager ?? new HttpManager(httpClientFactory);
     TelemetryManager          = new TelemetryManager(telemetryReceiver ?? Telemetry.GetInstance());
     ValidatedAuthoritiesCache = validatedAuthoritiesCache ?? new ValidatedAuthoritiesCache(shouldClearCaches);
     AadInstanceDiscovery      = aadInstanceDiscovery ?? new AadInstanceDiscovery(HttpManager, TelemetryManager, shouldClearCaches);
     WsTrustWebRequestManager  = wsTrustWebRequestManager ?? new WsTrustWebRequestManager(HttpManager);
     PlatformProxy             = PlatformProxyFactory.GetPlatformProxy();
 }
        internal ServiceBundle(
            ApplicationConfiguration config,
            bool shouldClearCaches = false)
        {
            Config = config;

            DefaultLogger = new MsalLogger(
                Guid.Empty,
                config.ClientName,
                config.ClientVersion,
                config.LogLevel,
                config.EnablePiiLogging,
                config.IsDefaultPlatformLoggingEnabled,
                config.LoggingCallback);

            PlatformProxy = config.PlatformProxy ?? PlatformProxyFactory.CreatePlatformProxy(DefaultLogger);
            HttpManager   = config.HttpManager ?? new HttpManager(config.HttpClientFactory);

            HttpTelemetryManager = new HttpTelemetryManager();
            if (config.TelemetryConfig != null)
            {
                // This can return null if the device isn't sampled in.  There's no need for processing MATS events if we're not going to send them.
                Mats = TelemetryClient.CreateMats(config, PlatformProxy, config.TelemetryConfig);
                MatsTelemetryManager = Mats?.TelemetryManager ??
                                       new TelemetryManager(config, PlatformProxy, config.TelemetryCallback);
            }
            else
            {
                MatsTelemetryManager = new TelemetryManager(config, PlatformProxy, config.TelemetryCallback);
            }

            InstanceDiscoveryManager = new InstanceDiscoveryManager(
                HttpManager,
                MatsTelemetryManager,
                shouldClearCaches,
                config.CustomInstanceDiscoveryMetadata,
                config.CustomInstanceDiscoveryMetadataUri);

            WsTrustWebRequestManager           = new WsTrustWebRequestManager(HttpManager);
            ThrottlingManager                  = SingletonThrottlingManager.GetInstance();
            AuthorityEndpointResolutionManager = new AuthorityEndpointResolutionManager(this, shouldClearCaches);
            DeviceAuthManager                  = PlatformProxy.CreateDeviceAuthManager();
        }
        public static IDictionary <string, string> GetMsalIdParameters(ICoreLogger logger)
        {
            var platformProxy = PlatformProxyFactory.CreatePlatformProxy(logger);

            if (platformProxy == null)
            {
                throw new MsalClientException(
                          MsalError.PlatformNotSupported,
                          MsalErrorMessage.PlatformNotSupported);
            }

            var parameters = new Dictionary <string, string>
            {
                [MsalIdParameter.Product] = platformProxy.GetProductName(),
                [MsalIdParameter.Version] = GetMsalVersion()
            };

            string processorInformation = platformProxy.GetProcessorArchitecture();

            if (processorInformation != null)
            {
                parameters[MsalIdParameter.CpuPlatform] = processorInformation;
            }

            string osInformation = platformProxy.GetOperatingSystem();

            if (osInformation != null)
            {
                parameters[MsalIdParameter.OS] = osInformation;
            }

            string deviceInformation = platformProxy.GetDeviceModel();

            if (deviceInformation != null)
            {
                parameters[MsalIdParameter.DeviceModel] = deviceInformation;
            }

            return(parameters);
        }