Beispiel #1
0
        private bool TryExportResourceFiles(IEnumerable <string> resourceNames, string outputDirectory, bool overwrite, string regexFilter = null)
        {
            if (string.IsNullOrEmpty(outputDirectory))
            {
                throw new ArgumentNullException(nameof(outputDirectory));
            }
            if (!resourceNames.Any())
            {
                return(false);
            }
            bool isEmpty = true;

            using (var templateResource = new CompositeResourceCollectionWithOverridden(resourceNames.Select(s => _finder.Find(s)).Where(s => s != null)))
            {
                if (templateResource.IsEmpty)
                {
                    Logger.Log(LogLevel.Warning, $"No resource found for [{resourceNames.ToDelimitedString()}].");
                }
                else
                {
                    foreach (var pair in templateResource.GetResourceStreams(regexFilter))
                    {
                        var outputPath = Path.Combine(outputDirectory, pair.Key);
                        CopyResource(pair.Value, outputPath, overwrite);
                        Logger.Log(LogLevel.Verbose, $"File {pair.Key} copied to {outputPath}.");
                        isEmpty = false;
                    }
                }

                return(!isEmpty);
            }
        }
Beispiel #2
0
        private bool TryExportResourceFiles(IEnumerable<string> resourceNames, string outputDirectory, bool overwrite, string regexFilter = null)
        {
            if (string.IsNullOrEmpty(outputDirectory)) throw new ArgumentNullException(nameof(outputDirectory));
            if (!resourceNames.Any()) return false;
            bool isEmpty = true;
            using (var templateResource = new CompositeResourceCollectionWithOverridden(resourceNames.Select(s => _finder.Find(s)).Where(s => s != null)))
            {
                if (templateResource.IsEmpty)
                {
                    Logger.Log(LogLevel.Warning, $"No resource found for [{resourceNames.ToDelimitedString()}].");
                }
                else
                {
                    foreach (var pair in templateResource.GetResourceStreams(regexFilter))
                    {
                        var outputPath = Path.Combine(outputDirectory, pair.Key);
                        CopyResource(pair.Value, outputPath, overwrite);
                        Logger.Log(LogLevel.Verbose, $"File {pair.Key} copied to {outputPath}.");
                        isEmpty = false;
                    }
                }

                return !isEmpty;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Template can contain a set of plugins to define the behavior of how to generate the output YAML data model
 /// The name of plugin folder is always "plugins"
 /// </summary>
 public IEnumerable <KeyValuePair <string, Stream> > GetTemplatePlugins()
 {
     using (var templateResource = new CompositeResourceCollectionWithOverridden(_templates.Select(s => _finder.Find(s)).Where(s => s != null)))
     {
         if (templateResource.IsEmpty)
         {
             yield break;
         }
         else
         {
             foreach (var pair in templateResource.GetResourceStreams(@"^plugins/.*"))
             {
                 yield return(pair);
             }
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Template can contain a set of plugins to define the behavior of how to generate the output YAML data model
 /// The name of plugin folder is always "plugins"
 /// </summary>
 public IEnumerable<KeyValuePair<string, Stream>> GetTemplatePlugins()
 {
     using (var templateResource = new CompositeResourceCollectionWithOverridden(_templates.Select(s => _finder.Find(s)).Where(s => s != null)))
     {
         if (templateResource.IsEmpty)
         {
             yield break;
         }
         else
         {
             foreach (var pair in templateResource.GetResourceStreams(@"^plugins/.*"))
             {
                 yield return pair;
             }
         }
     }
 }