Ejemplo n.º 1
0
 public override IEnumerable <SourcingResult> Generate(SourcingContext context)
 {
     yield return(new SourcingResult()
     {
         Provider = new HttpStreamProvider(_uri)
     });
 }
 public override IEnumerable <SourcingResult> Generate(SourcingContext context)
 {
     yield return(new SourcingResult
     {
         FileName = _filename,
         Provider = new StringStreamProvider(_string),
     });
 }
        public override IEnumerable <SourcingResult> Generate(SourcingContext context)
        {
            var resources = _assembly.GetManifestResourceNames();

            foreach (var resource in resources.Where(r => r.StartsWith(_resourcePath)))
            {
                yield return(new ResourceFileSourceFactory(resource, _assembly).Generate(context).First());
            }
        }
        public override IEnumerable <SourcingResult> Generate(SourcingContext context)
        {
            var match    = Regex.Match(_resourcePath, @"\.[^\.]*\.", RegexOptions.RightToLeft);
            var ix       = match.Success ? match.Index : -1;
            var fileName = _resourcePath.Substring(ix);

            yield return(new SourcingResult
            {
                FileName = fileName,
                Provider = new AssemblyManifestStreamProvider(_resourceAssembly(), _resourcePath)
            });
        }
Ejemplo n.º 5
0
        public override IEnumerable <SourcingResult> Generate(SourcingContext context)
        {
            var absolutePath = AssembleFilePath(context, _relativePath);

            if (!File.Exists(absolutePath))
            {
                throw new FileNotFoundException($"The specified file '{absolutePath}' could not be found.");
            }

            var fileName = Path.GetFileName(absolutePath);

            yield return(new SourcingResult
            {
                FileName = fileName,
                Provider = new OpenFileStreamProvider(absolutePath),
                FilePath = absolutePath
            });
        }
        public override IEnumerable <SourcingResult> Generate(SourcingContext context)
        {
            var glob  = context.TemplateRoot.FullName + _globPattern;
            var files = Glob.Expand(glob);

            foreach (var file in files)
            {
                // Maybe should throw here?
                if (!File.Exists(file.FullName))
                {
                    continue;
                }

                var fileRelativePath = file.FullName.Replace(context.TemplateRoot.FullName, "");
                yield return(new SourcingResult
                {
                    FilePath = fileRelativePath,
                    FileName = fileRelativePath,
                    Provider = new OpenFileStreamProvider(file.FullName)
                });
            }
        }
Ejemplo n.º 7
0
 protected abstract string AssembleFilePath(SourcingContext context, string relativePath);
Ejemplo n.º 8
0
 protected override string AssembleFilePath(SourcingContext context, string relativePath)
 => Path.Combine(context.TemplateRoot.FullName, relativePath);
Ejemplo n.º 9
0
 public abstract IEnumerable <SourcingResult> Generate(SourcingContext context);