Beispiel #1
0
        public void CreateMetadataEmbed(IMetadataConverter metadataConverter, Metadata metadata)
        {
            string result;

            if (metadataConverter.Write(metadata, out result))
            {
                string filePath;
                if (PathFormatter.IsEnabled)
                {
                    filePath = PathFormatter.GetConvertedMetadata(metadata, metadataConverter);
                }
                else
                {
                    filePath = string.Format(CultureInfo.InvariantCulture, "{0}{1}/{2}", PathFormatter.GetCacheDirectory(), metadata.Id, metadataConverter.FileName);
                }

                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                    File.WriteAllText(filePath, result);
                }
                catch (Exception ex)
                {
                    Logger.ErrorLineFormat("Failed to write metadata embed: {0}", filePath);
                    Logger.ErrorLineFormat(ex.ToString());
                }
            }
        }
        public MetadataExtractor(IMetadataConverter converter)
        {
            ArgumentUtility.CheckNotNull("converter", converter);

            _assemblies = new List <Assembly> ();
            _converter  = converter;
        }
        public void Create_SimpleMetadataToXmlConverter()
        {
            _converterBuilder.ConvertMetadataToXml = true;

            IMetadataConverter converter = _converterBuilder.Create();

            Assert.IsInstanceOf(typeof(MetadataToXmlConverter), converter);
        }
Beispiel #4
0
 public string GetConvertedMetadata(Metadata metadata, IMetadataConverter metadataConverter)
 {
     return(GetPath(ConfigPaths?.ConvertedMetadata, metadata, new Dictionary <string, string>()
     {
         { "FileName", metadataConverter.FileName },
         { "FileTitle", Path.GetFileNameWithoutExtension(metadataConverter.FileName) },
         { "FileExt", Path.GetExtension(metadataConverter.FileName) },
     }));
 }
        public void Create_LocalizingConverterForOneCultureInfo()
        {
            _converterBuilder.AddLocalization(new CultureInfo("de"));

            IMetadataConverter converter = _converterBuilder.Create();

            Assert.IsInstanceOf(typeof(LocalizingMetadataConverter), converter);
            LocalizingMetadataConverter localizingConverter = (LocalizingMetadataConverter)converter;

            Assert.That(localizingConverter.MetadataConverter, Is.Null);
            Assert.That(localizingConverter.Cultures.Length, Is.EqualTo(1));
            Assert.That(localizingConverter.Cultures[0].TwoLetterISOLanguageName, Is.EqualTo("de"));
        }
        public void Create_LocalizingConverterWithInvariantCulture()
        {
            _converterBuilder.AddLocalization("de");
            _converterBuilder.AddLocalization(CultureInfo.InvariantCulture);

            IMetadataConverter converter = _converterBuilder.Create();

            Assert.IsInstanceOf(typeof(LocalizingMetadataConverter), converter);
            LocalizingMetadataConverter localizingConverter = (LocalizingMetadataConverter)converter;

            Assert.That(localizingConverter.MetadataConverter, Is.Null);
            Assert.That(localizingConverter.Cultures.Length, Is.EqualTo(2));
            Assert.That(localizingConverter.Cultures[0].TwoLetterISOLanguageName, Is.EqualTo("de"));
            Assert.That(localizingConverter.Cultures[1].TwoLetterISOLanguageName, Is.EqualTo(CultureInfo.InvariantCulture.TwoLetterISOLanguageName));
        }
        public void Create_LocalizingConverterWithMetadataToXmlConverter()
        {
            _converterBuilder.AddLocalization("de");
            _converterBuilder.AddLocalization("fr");
            _converterBuilder.ConvertMetadataToXml = true;

            IMetadataConverter converter = _converterBuilder.Create();

            Assert.IsInstanceOf(typeof(LocalizingMetadataConverter), converter);
            LocalizingMetadataConverter localizingConverter = (LocalizingMetadataConverter)converter;

            Assert.IsInstanceOf(typeof(MetadataToXmlConverter), localizingConverter.MetadataConverter);
            Assert.That(localizingConverter.Cultures.Length, Is.EqualTo(2));
            Assert.That(localizingConverter.Cultures[0].TwoLetterISOLanguageName, Is.EqualTo("de"));
            Assert.That(localizingConverter.Cultures[1].TwoLetterISOLanguageName, Is.EqualTo("fr"));
        }
Beispiel #8
0
 public MetadataParser(IMetadataConverter converter)
 {
     this.converter = converter;
 }
Beispiel #9
0
 public void SetUp()
 {
     _mocks = new MockRepository();
     _localizationConverter = _mocks.StrictMock <IMetadataLocalizationConverter> ();
     _metadataConverter     = _mocks.StrictMock <IMetadataConverter> ();
 }