WorkbookPublishSettings.GetSettingsForSavedWorkbook C# (CSharp) Method

GetSettingsForSavedWorkbook() static private method

Look up any saved settings we have associated with a workbook on our local file systemm
static private GetSettingsForSavedWorkbook ( string workbookWithPath ) : WorkbookPublishSettings,
workbookWithPath string
return WorkbookPublishSettings,
    internal static WorkbookPublishSettings GetSettingsForSavedWorkbook(string workbookWithPath)
    {
        //Sanity test: If the workbook is not there, then we probably have an incorrect path
        AppDiagnostics.Assert(File.Exists(workbookWithPath), "Underlying workbook does not exist");

        //Find the path to the settings file
        var pathToSettingsFile = PathForSettingsFile(workbookWithPath);
        if(!File.Exists(pathToSettingsFile))
        {
            return GenerateDefaultSettings();
        }

        //===================================================================
        //We've got a setings file, let's parse it!
        //===================================================================
        var xmlDoc = new XmlDocument();
        xmlDoc.Load(pathToSettingsFile);

        //Show sheets
        bool showSheetsInTabs = ParseXml_GetShowSheetsAsTabs(xmlDoc);
        string ownerName = ParseXml_GetOwnerName(xmlDoc);

        //Return the Settings data
        return new WorkbookPublishSettings(showSheetsInTabs, ownerName);
    }

Usage Example

 /// <summary>
 /// Look up settings associated with this content
 /// </summary>
 /// <param name="workbookWithPath"></param>
 /// <returns></returns>
 WorkbookPublishSettings helper_DetermineContentPublishSettings(string workbookWithPath)
 {
     return(WorkbookPublishSettings.GetSettingsForSavedWorkbook(workbookWithPath));
 }