public void Load([NotNull] string fileName) { Assert.ArgumentNotNull(fileName, nameof(fileName)); XDocument doc; try { doc = XDocument.Load(fileName); } catch { return; } var root = doc.Root; if (root == null) { return; } var name = root.GetAttributeValue("Generator"); if (string.IsNullOrEmpty(name)) { return; } GeneratorName = name; Generator = CodeGenerationManager.GetGenerator(name); if (Generator == null) { return; } Generator.Pane = Pane; Generator.Load(root); var control = Generator.GetConfigurationUserControl(); if (control == null) { control = new GenericConfigurator(this); } Configurator.Child = control; }
protected override string GetOutput() { XDocument doc; try { doc = XDocument.Parse(InputFileContents); } catch { return("// The input file is not a valid XML document."); } var root = doc.Root; if (root == null) { return("// The input file is not a valid XML document."); } var name = root.GetAttributeValue("Generator"); if (string.IsNullOrEmpty(name)) { return("// The Generator attribute on the root element is missing."); } var generator = CodeGenerationManager.GetGenerator(name); if (generator == null) { return("// The expected generator \"{0}\" was not found."); } generator.Load(root); var site = GetSite(); var fileName = InputFilePath; return(generator.GetOutput(fileName, site)); }