Example #1
0
        public static void Configure(Action <FlurlHttpSettings> configureFlurl = null, Action <OpenStackNetConfigurationOptions> configure = null)
        {
            lock (ConfigureLock)
            {
                if (_isConfigured)
                {
                    // Check if a user is attempting to apply custom configuration after the default config has been applied
                    if (configureFlurl != null || configure != null)
                    {
                        Trace.TraceError("Ignoring additional call to OpenStackNet.Configure. It can only be called once at application start-up, before instantiating any OpenStack.NET objects.");
                    }

                    return;
                }

                // Give the application an opportunity to tweak the default config
                _config = OpenStackNetConfigurationOptions.Create();
                Configuring?.Invoke(_config);

                // Apply legacy custom configuration, removed in 2.0 as it's replaced by the Configuring event
                configureFlurl?.Invoke(_config.FlurlHttpSettings);

                // Finish configuration and lock it
                _config.CompleteInitialization();

                _isConfigured = true;
            }
        }
Example #2
0
 /// <summary>
 /// <par>Resets all configuration (OpenStack.NET, Flurl and Json.NET).</par>
 /// <para>After this is called, you must re-register any <see cref="Configuring"/> event handlers.</para>
 /// </summary>
 public static void ResetDefaults()
 {
     lock (ConfigureLock)
     {
         _config       = null;
         Configuring   = null;
         _isConfigured = false;
     }
 }
 internal void Apply(OpenStackNetConfigurationOptions target)
 {
     target.UserAgents.Clear();
     UserAgents.ForEach(userAgent => target.UserAgents.Add(userAgent));
 }