Search code examples
c#cefsharp

Cefsharp: how to get value from settings?


Before opening the browser, Cefsharp initializes the settings. Is it possible to get something like a list of these same settings programmatically? For example in a message box?

public void InitializeChromium()
{
    settings = new CefSettings();
    settings.CefCommandLineArgs.Add("proxy-server", "127.0.0.1:8080");
    // ...etc
}

Example:

MessageBox.Show(settings.CefCommandLineArgs.Values.ToString());

Solution

  • CefSettings.CefCommandLineArgs is a IDictionary<string, string> so something like the following may do the job.

    var myArgs = string.Join(", ", settings.CefCommandLineArgs
            .Select( s => $"{s.Key}={s.Value}"));
    

    You may want to prettify it for settings with no values (flags).