Ejemplo n.º 1
0
        public bool ValidateMetadataRules()
        {
            var newDataSettings = GetDataSettings(DocumentContainer.DocumentUI.Settings.DataSettings);

            if (!newDataSettings.MetadataRuleSets.Any() || Equals(_originalSettings, newDataSettings))
            {
                return(true);
            }
            var document = DocumentContainer.DocumentUI;

            document = document.ChangeSettings(document.Settings.ChangeDataSettings(newDataSettings));
            MetadataExtractor.ApplyRules(document, null, out CommonException <MetadataExtractor.RuleError> error);
            if (error != null)
            {
                string message =
                    string.Format(
                        Resources.DocumentSettingsDlg_ValidateMetadataRules_An_error_occurred_while_applying_the_rule___0____Do_you_want_to_continue_with_the_change_to_the_Document_Settings_,
                        error.ExceptionDetail.RuleName);
                var alertDlg = new AlertDlg(message, MessageBoxButtons.OKCancel)
                {
                    Exception = error
                };
                if (alertDlg.ShowAndDispose(this) == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public async Task GetMetadata()
        {
            // Arrange
            Mock <IGeoDecoderService> mock = CreateGeoDecoderMock();
            Stream image             = TestMediaLibrary.WithExif;
            var    metadataExtractor = new MetadataExtractor(mock.Object);

            // Act
            MediaMetadata meta = await metadataExtractor.GetMetadataAsync(image, default);

            // Assert
            meta.MatchSnapshot();
        }
Ejemplo n.º 3
0
        public MetadataRuleEditor(IDocumentContainer documentContainer)
        {
            InitializeComponent();
            _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var rootColumn  = ColumnDescriptor.RootColumn(_dataSchema, typeof(ResultFile));
            var viewContext =
                new SkylineViewContext(rootColumn, new StaticRowSource(new ExtractedMetadataResultRow[0]));

            _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile));
            bindingListSource1.SetViewContext(viewContext);
            var sources = _metadataExtractor.GetSourceColumns().ToArray();

            comboSourceText.Items.AddRange(sources);
            comboMetadataTarget.Items.AddRange(_metadataExtractor.GetTargetColumns().ToArray());
            SelectItem(comboSourceText, PropertyPath.Root.Property(nameof(ResultFile.FileName)));
            FormatCultureInfo = CultureInfo.InvariantCulture;
        }
Ejemplo n.º 4
0
        private static int ExtractMetadata(CommandLineArguments arguments)
        {
            try
            {
                MetadataExtractor extractor = new MetadataExtractor(GetMetadataConverter(arguments));

                extractor.AddAssembly(arguments.DomainAssemblyName);
                extractor.Save(arguments.MetadataOutputFile);
            }
            catch (Exception e)
            {
                HandleException(e, arguments.Verbose);
                return(1);
            }

            return(0);
        }