コード例 #1
0
        /// <summary>
        /// Load 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 LoadProjectSettingsAsync(int projectID)
        {
            // clear any existing settings
            if (Settings != null)
            {
                Settings.Clear();
            }
            else
            {
                Settings = new Dictionary <string, string>();
            }

            // reset the module level variable
            GenerateComment = false;

            // retrieve the module settings
            string projectSettings = await ProjectModule.GetModuleSettingsAsync(projectID, MODULE_NAME);

            if (String.IsNullOrEmpty(projectSettings))
            {
                return;
            }

            // create a XDocument from the stored string
            XDocument projectSettingsXDoc = XDocument.Parse(projectSettings);

            // turn the XDocument into a dictionary
            Settings = projectSettingsXDoc.Root.Descendants().ToDictionary(c => c.Name.LocalName, c => c.Value);

            if (Settings.ContainsKey(GENCOMMENT_NAME))
            {
                GenerateComment = Convert.ToBoolean(Settings[GENCOMMENT_NAME]);
            }
        }