示例#1
0
        private static void TryAndExportAdmTemplate(ManageableConfigurationSourceElementNode sourceNode)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.AddExtension = true;
            dialog.Filter       = Resources.AdmTemplateDialogFilter;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                IDictionary <String, ConfigurationSectionManageabilityProvider> manageabilityProviders = GetManageabilityProviders();
                try
                {
                    AdmContent content = AdministrativeTemplateGenerator.GenerateAdministrativeTemplateContent(
                        sourceNode.ConfigurationSource,
                        sourceNode.ApplicationName,
                        manageabilityProviders);

                    using (StreamWriter fileWriter = new StreamWriter(dialog.OpenFile()))
                    {
                        fileWriter.WriteLine("CLASS MACHINE");
                        content.Write(fileWriter);
                        fileWriter.WriteLine("CLASS USER");
                        content.Write(fileWriter);
                        fileWriter.Flush();
                        fileWriter.Close();
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(String.Format(Resources.Culture, Resources.ErrorGeneratingAdmFile, e.Message),
                                    Resources.AdmGenerationDialogErrorTitle,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ManageableConfigurationSourceElementNode sourceNode = node as ManageableConfigurationSourceElementNode;

            if (sourceNode != null)
            {
                // check current configuration == selected configuration?

                // check for dirty and ask for saving
                if (UIService.IsDirty(node.Hierarchy))
                {
                    DialogResult result
                        = UIService.ShowMessage(Resources.SaveApplicationBeforeExportingAdmRequest,
                                                Resources.SaveApplicationCaption,
                                                MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        if (!TryAndSaveApplication(node))
                        {
                            return;
                        }
                    }
                }

                TryAndExportAdmTemplate(sourceNode);
            }
        }
示例#3
0
 public ManageableConfigurationSourceElementBuilder(ManageableConfigurationSourceElementNode node,
                                                    ConfigurationManageabilityProviderAttributeRetriever retriever)
 {
     this.node      = node;
     this.retriever = retriever;
 }
示例#4
0
 public ManageableConfigurationSourceElementBuilder(ManageableConfigurationSourceElementNode node)
     : this(node, new ConfigurationManageabilityProviderAttributeRetriever())
 {
 }