Beispiel #1
0
 /// <summary>
 /// Retries all files from a relative directory.
 /// </summary>
 /// <param name="relativeDirectory">Relative directory name.</param>
 /// <returns>File names.</returns>
 public string[] RetrieveAllFileNames(string relativeDirectory)
 {
     if (!NameToContentMap.TryGetValue(relativeDirectory, out var filesMap))
     {
         throw new DirectoryNotFoundException("Could not find directory " + relativeDirectory);
     }
     return(filesMap.Select(x => x.Key).ToArray());
 }
        /// <summary>
        /// Allows files to be stored for later retrieval. Used for testing purposes.
        /// </summary>
        /// <param name="files">Files used by the template service.</param>
        /// <returns>Array of file paths.</returns>
        public virtual string[] InputFiles(params InputFile[] files)
        {
            var filePaths = new List <string>();

            foreach (var file in files)
            {
                if (!NameToContentMap.TryGetValue(file.Directory, out var filesMap))
                {
                    filesMap = new Dictionary <string, string>();
                    NameToContentMap[file.Directory] = filesMap;
                }

                filesMap[file.File] = file.Contents;

                var path = Path.Combine(file.Directory, file.File);
                filePaths.Add(path);
            }

            return(filePaths.ToArray());
        }