示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This method is used to update all files of the given type when a filed is being
        /// renamed or deleted. The ComponentFile supplied should be the one that was "active"
        /// when the delete or rename occurred (it will be skipped since it is assumed that the
        /// change was already done there).
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void FindAndUpdateFiles(ComponentFile file, string idOfFieldToFind,
                                        Action <List <FieldInstance>, FieldInstance> updateAction)
        {
            // Since the field being removed or renamed is *no longer* a factory field, it
            // will be loaded as a custom field (having prefix "custom_", so if the caller
            // passes the field name without that prefix, we need to add it.
            if (!idOfFieldToFind.StartsWith(XmlFileSerializer.kCustomFieldIdPrefix))
            {
                idOfFieldToFind = XmlFileSerializer.kCustomFieldIdPrefix + idOfFieldToFind;
            }

            var matchingFiles = GetMatchingFiles(file.FileType);

            if (_fieldGatherer != null)
            {
                _fieldGatherer.SuspendProcessing();
            }

            foreach (var path in matchingFiles)
            {
                if (file.PathToAnnotatedFile == path)
                {
                    continue;
                }

                var sidecarFilePath = file.FileType.GetMetaFilePath(path);
                if (!File.Exists(sidecarFilePath))
                {
                    continue;
                }

                var metaDataFields = new List <FieldInstance>();
                _xmlFileSerializer.Load(metaDataFields, sidecarFilePath, file.RootElementName, file.FileType);

                var field = metaDataFields.Find(x => x.FieldId == idOfFieldToFind);
                if (field != null)
                {
                    updateAction(metaDataFields, field);
                    _xmlFileSerializer.Save(metaDataFields, sidecarFilePath, file.RootElementName);
                    if (_fieldGatherer != null)
                    {
                        _fieldGatherer.GatherFieldsForFileNow(sidecarFilePath);
                    }
                }
            }

            if (_fieldGatherer != null)
            {
                _fieldGatherer.ResumeProcessing(false);
            }
        }
        /// ------------------------------------------------------------------------------------
        public void SaveIdForIndex(int index, string newId)
        {
            if (newId == null || newId.Trim() == string.Empty)
            {
                return;
            }

            newId = GetFieldNameToSerialize(newId);

            if (index == RowData.Count)
            {
                RowData.Add(new FieldInstance(newId));
            }
            else if (RowData[index].FieldId != newId)
            {
                _fieldGatherer.SuspendProcessing();
                _file.RenameId(RowData[index].FieldId, newId);
                RowData[index].FieldId = newId;
                _file.Save();
                _fieldGatherer.GatherFieldsForFileNow(_file.PathToAnnotatedFile);
                _fieldGatherer.ResumeProcessing(true);
            }
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        public void ResumeBackgroundProcesses(bool processAllPendingEventsNow)
        {
            if (_audioVideoDataGatherer != null)
            {
                _audioVideoDataGatherer.ResumeProcessing(processAllPendingEventsNow);
            }

            if (_autoCompleteValueGatherer != null)
            {
                _autoCompleteValueGatherer.ResumeProcessing(processAllPendingEventsNow);
            }

            if (_fieldGatherer != null)
            {
                _fieldGatherer.ResumeProcessing(processAllPendingEventsNow);
            }

            if (_presetGatherer != null)
            {
                _presetGatherer.ResumeProcessing(processAllPendingEventsNow);
            }
        }