public string PublishToString(IssueLogger issues) { string outputFilenameSuffix = ""; Logger.Info("Begin creating metadata file with documentation annotations."); // Step 1: Generate an EntityFramework OM from the documentation and/or template file EntityFramework framework = CreateEntityFrameworkFromDocs(issues); if (null == framework) { return(string.Empty); } // Step 1a: Apply an transformations that may be defined in the documentation if (!string.IsNullOrEmpty(options.TransformOutput)) { PublishSchemaChangesConfigFile transformations = DocSet.TryLoadConfigurationFiles <PublishSchemaChangesConfigFile>(options.DocumentationSetPath).Where(x => x.SchemaChanges.TransformationName == options.TransformOutput).FirstOrDefault(); if (null == transformations) { throw new KeyNotFoundException($"Unable to locate a transformation set named {options.TransformOutput}. Aborting."); } string[] versionsToPublish = options.Version?.Split(new char[] { ',', ' ' }); framework.ApplyTransformation(transformations.SchemaChanges, versionsToPublish); if (!string.IsNullOrEmpty(options.Version)) { outputFilenameSuffix += $"-{options.Version}"; } } if (options.Sort) { // Sorts the objects in collections, so that we have consistent output regardless of input framework.SortObjectGraph(); } if (options.ValidateSchema) { framework.ValidateSchemaTypes(); } // Step 2: Generate XML representation of EDMX string xmlData = ODataParser.Serialize <EntityFramework>(framework, options.AttributesOnNewLines); Logger.Info("Finish creating metadata file with documentation annotations."); return(xmlData); }
public static void LoadCurrentConfiguration(DocSetOptions options) { if (CurrentConfiguration != null) { return; } if (null != options) { var configurationFiles = DocSet.TryLoadConfigurationFiles <AppConfigFile>(options.DocumentationSetPath); CurrentConfiguration = configurationFiles.FirstOrDefault(); if (null != CurrentConfiguration) { Console.WriteLine("Using configuration file: {0}", CurrentConfiguration.SourcePath); } } }
public override async Task PublishToFolderAsync(string outputFolder) { string outputFilenameSuffix = null; // Step 1: Generate an EntityFramework OM from the documentation and/or template file EntityFramework framework = CreateEntityFrameworkFromDocs(); if (null == framework) { return; } // Step 1a: Apply an transformations that may be defined in the documentation if (!string.IsNullOrEmpty(options.TransformOutput)) { PublishSchemaChangesConfigFile transformations = DocSet.TryLoadConfigurationFiles <PublishSchemaChangesConfigFile>(options.DocumentationSetPath).Where(x => x.SchemaChanges.TransformationName == options.TransformOutput).FirstOrDefault(); if (null == transformations) { throw new KeyNotFoundException($"Unable to locate a transformation set named {options.TransformOutput}. Aborting."); } string[] versionsToPublish = options.Version?.Split(new char[] { ',', ' ' }); framework.ApplyTransformation(transformations.SchemaChanges, versionsToPublish); if (!string.IsNullOrEmpty(options.Version)) { outputFilenameSuffix = $"-{options.Version}"; } } if (options.Sort) { // Sorts the objects in collections, so that we have consistent output regardless of input framework.SortObjectGraph(); } if (options.ValidateSchema) { framework.ValidateSchemaTypes(); } // Step 2: Generate XML representation of EDMX string xmlData = null; if (options.Formats.HasFlag(MetadataFormat.EdmxOutput)) { xmlData = ODataParser.Serialize <EntityFramework>(framework, options.AttributesOnNewLines); } else if (options.Formats.HasFlag(MetadataFormat.SchemaOutput)) { xmlData = ODataParser.Serialize <Schema>(framework.DataServices.Schemas.First(), options.AttributesOnNewLines); } // Step 3: Write the XML to disk var outputFullName = GenerateOutputFileFullName(options.SourceMetadataPath, outputFolder, outputFilenameSuffix); Console.WriteLine($"Publishing metadata to {outputFullName}"); using (var writer = System.IO.File.CreateText(outputFullName)) { await writer.WriteAsync(xmlData); await writer.FlushAsync(); writer.Close(); } }