Smrf.NodeXL.ExcelTemplate.TaskAutomator.GetGraphGalleryAuthorAndPassword C# (CSharp) Method

GetGraphGalleryAuthorAndPassword() private static method

private static GetGraphGalleryAuthorAndPassword ( ExportToNodeXLGraphGalleryUserSettings oExportToNodeXLGraphGalleryUserSettings, String &sAuthor, String &sPassword ) : void
oExportToNodeXLGraphGalleryUserSettings ExportToNodeXLGraphGalleryUserSettings
sAuthor String
sPassword String
return void
    GetGraphGalleryAuthorAndPassword
    (
        ExportToNodeXLGraphGalleryUserSettings
            oExportToNodeXLGraphGalleryUserSettings,

        out String sAuthor,
        out String sPassword
    )
    {
        Debug.Assert(oExportToNodeXLGraphGalleryUserSettings != null);

        // The user may have automated the graph without ever opening the
        // ExportToNodeXLGraphGalleryDialog to specify an author and password.
        // This can be worked around.
        //
        // The NodeXLGraphGalleryExporter class requires one of the following:
        //
        // 1. An author that is the name of a Graph Gallery account, along with
        //    the password for that account.
        //
        // 2. A guest author name, with a null password.

        sAuthor = oExportToNodeXLGraphGalleryUserSettings.Author;

        if ( String.IsNullOrEmpty(sAuthor) )
        {
            // The user hasn't specified an author or password yet.  Export the
            // graph as a guest.
            //
            // Note that there is nothing special about the word "Guest": there
            // is no such Graph Gallery account with that name.  Any name could
            // be used here.

            sAuthor = "Guest";
            sPassword = null;
        }
        else
        {
            // The user specified either the name of a Graph Gallery account
            // along with a password, or a guest name.  In the first case, the
            // saved password is non-empty; in the second case, it's empty.

            sPassword =
                ( new PasswordUserSettings() ).NodeXLGraphGalleryPassword;

            if (sPassword.Length == 0)
            {
                sPassword = null;
            }
        }
    }