예제 #1
0
        /// <summary>
        /// Save the custom editing settings from the given project. The settings will change extension specific
        /// properties for this edit tool sample.
        /// </summary>
        /// <param name="projectID">Project ID</param>
        /// <returns></returns>
        private async Task SaveProjectSettingsAsync(int projectID)
        {
            // check if the internal settings dictionary is valid, otherwise create one
            if (Settings == null)
            {
                Settings = new Dictionary <string, string>();
            }

            // update the settings dictionary with the current state of the module level variable
            if (Settings.ContainsKey(GENCOMMENT_NAME))
            {
                Settings[GENCOMMENT_NAME] = GenerateComment.ToString();
            }
            else
            {
                Settings.Add(GENCOMMENT_NAME, GenerateComment.ToString());
            }

            // transform the dictionary into the xml representation
            var settingsXDoc = new XDocument(new XElement(MODULE_NAME, Settings.Select(i => new XElement(i.Key, i.Value))));

            // store the project based settings
            await ProjectModule.PutModuleSettingsAsync(projectID, MODULE_NAME, settingsXDoc.ToString(SaveOptions.DisableFormatting));
        }