コード例 #1
0
        public IFileInfo GetFileInfo(string subpath)
        {
            if (_lookup.ContainsKey(subpath))
            {
                return(_lookup[subpath]);
            }
            else
            {
                var viewName             = Path.GetFileName(subpath);
                var lookupPath           = string.Format(_resourceTemplatePath, viewName);
                var mailTemplateFileInfo = new MailTemplateFileInfo();
                mailTemplateFileInfo.Name = viewName;
                using (Stream stream = _currentAssembly.GetManifestResourceStream(lookupPath))
                {
                    if (stream == null)
                    {
                        throw new ArgumentNullException(nameof(stream));
                    }

                    using (StreamReader sr = new StreamReader(stream, Encoding.UTF8))
                    {
                        mailTemplateFileInfo.Content = sr.ReadToEnd();
                    }
                }

                AddFile(subpath, mailTemplateFileInfo);
                return(mailTemplateFileInfo);
            }
        }
コード例 #2
0
        public MailTemplateFileInfo AddFile(string path, string contents)
        {
            var fileInfo = new MailTemplateFileInfo
            {
                Content      = contents,
                Name         = Path.GetFileName(path),
                LastModified = DateTime.UtcNow,
            };

            AddFile(path, fileInfo);

            return(fileInfo);
        }