Пример #1
0
 /// ------------------------------------------------------------------------------------
 public ComponentFileFactory(IEnumerable <FileType> fileTypes,
                             IEnumerable <ComponentRole> componentRoles, XmlFileSerializer xmlFileSerializer,
                             IProvideAudioVideoFileStatistics statisticsProvider,
                             PresetGatherer presetProvider, FieldUpdater fieldUpdater)
 {
     _fileTypes          = fileTypes;
     _componentRoles     = componentRoles;
     _xmlFileSerializer  = xmlFileSerializer;
     _statisticsProvider = statisticsProvider;
     _presetProvider     = presetProvider;
     _fieldUpdater       = fieldUpdater;
 }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>Removes the given (custom) field from this file's meta-data and also
        /// updates all other component files of this type if possible.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public virtual void RemoveField(string idToRemove)
        {
            var existingValue = MetaDataFieldValues.Find(f => f.FieldId == idToRemove);

            if (existingValue != null)
            {
                MetaDataFieldValues.Remove(existingValue);
            }

            if (FieldUpdater != null)
            {
                FieldUpdater.DeleteField(this, idToRemove);
            }
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        public virtual void RenameId(string oldId, string newId)
        {
            var fieldValue = MetaDataFieldValues.Find(v => v.FieldId == oldId);

            if (fieldValue != null)
            {
                fieldValue.FieldId = newId;
            }

            if (FieldUpdater != null)
            {
                FieldUpdater.RenameField(this, oldId, newId);
            }
        }
Пример #4
0
        /// ------------------------------------------------------------------------------------
        public void Dispose()
        {
            if (_annotationFile != null)
            {
                _annotationFile.Dispose();
            }
            _annotationFile = null;

            _xmlFileSerializer  = null;
            _statisticsProvider = null;
            _presetProvider     = null;
            _fieldUpdater       = null;
            MetaDataFieldValues = null;
            ParentElement       = null;
        }
Пример #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// used only by ProjectElementComponentFile and AnnotationComponentFile
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected ComponentFile(ProjectElement parentElement, string filePath,
                         FileType fileType, string rootElementName,
                         XmlFileSerializer xmlFileSerializer, FieldUpdater fieldUpdater)
 {
     RootElementName = rootElementName;
     ParentElement   = parentElement;
     //The annotated file is the same as the annotation file; there isn't a pair of files for session/person
     SetPathToFile(filePath);
     FileType            = fileType;
     _xmlFileSerializer  = xmlFileSerializer;
     _metaDataPath       = filePath;
     _fieldUpdater       = fieldUpdater;
     MetaDataFieldValues = new List <FieldInstance>();
     _componentRoles     = new ComponentRole[] {};         //no roles for person or event
     InitializeFileInfo();
 }
Пример #6
0
        /// ------------------------------------------------------------------------------------
        public ComponentFile(ProjectElement parentElement,
                             string pathToAnnotatedFile,
                             IEnumerable <FileType> fileTypes,
                             IEnumerable <ComponentRole> componentRoles,
                             XmlFileSerializer xmlFileSerializer,
                             IProvideAudioVideoFileStatistics statisticsProvider,
                             PresetGatherer presetProvider,
                             FieldUpdater fieldUpdater)
        {
            ParentElement = parentElement;
            SetPathToFile(pathToAnnotatedFile);
            _componentRoles     = componentRoles;
            _xmlFileSerializer  = xmlFileSerializer;
            _statisticsProvider = statisticsProvider;
            _presetProvider     = presetProvider;
            _fieldUpdater       = fieldUpdater;

            DetermineFileType(pathToAnnotatedFile, fileTypes);

            // we musn't do anything to remove the existing extension, as that is needed
            // to keep, say, foo.wav and foo.txt separate. Instead, we just append ".meta"
            //_metaDataPath = ComputeMetaDataPath(pathToAnnotatedFile);

            MetaDataFieldValues = new List <FieldInstance>();

            Guard.AgainstNull(FileType, "At runtime (maybe not in tests) FileType should go to a type intended for unknowns");

            _metaDataPath = FileType.GetMetaFilePath(pathToAnnotatedFile);

            RootElementName = "MetaData";

            if (File.Exists(_metaDataPath))
            {
                LoadNow();
            }

            InitializeFileInfo();
        }
 /// ------------------------------------------------------------------------------------
 public ProjectElementComponentFile(ProjectElement parentElement,
                                    FileType fileType, XmlFileSerializer xmlFileSerializer, string rootElementName, FieldUpdater fieldUpdater)
     : base(parentElement, parentElement.SettingsFilePath, fileType, rootElementName, xmlFileSerializer, fieldUpdater)
 {
     InitializeFileInfo();
 }