Example #1
0
        private void AssertMapping(MappingContent content, byte[] buffer)
        {
            AssertContent(content, MappingNamePattern, MappingFilePattern, buffer.Length);
            var ms = content.Buffer.ToMemoryStream();

            Assert.Equal(buffer, ms.ToArray());
        }
 private MappingDetails TransformFull(MappingContent content)
 {
     if (content != null)
     {
         var info    = OpenXmlSpreadsheet.GetMappingInfo(content.Buffer, null);
         var mapping = new MappingDetails();
         Transform(content, mapping);
         mapping.Buffer      = content.Buffer;
         mapping.Expressions = info.Expressions;
         mapping.Sources     = info.Sources;
         return(mapping);
     }
     return(null);
 }
Example #3
0
        public Task <MappingContent> GetMapping(string templateName, string templateVersion, string mappingName, string mappingVersion)
        {
            if (string.IsNullOrEmpty(templateName))
            {
                throw new ArgumentNullException(nameof(templateName));
            }
            if (string.IsNullOrEmpty(mappingName))
            {
                throw new ArgumentNullException(nameof(mappingName));
            }

            var fullName = Directory.GetFiles(MappingsFolder, $"{templateName}_{templateVersion ?? "*"}_{mappingName}_{mappingVersion ?? "*"}.xlsm")
                           .OrderByDescending(o => o)
                           .FirstOrDefault();
            MappingContent result = null;

            if (fullName != null && File.Exists(fullName))
            {
                result = ContentItemFactory.BuildMapping(fullName, ReadContents(fullName));
            }
            return(Task.FromResult(result));
        }