Пример #1
0
        /// ------------------------------------------------------------------------------------
        public virtual string GetStringValue(string key, string defaultValue)
        {
            string computedValue = null;

            var computedFieldInfo =
                FileType.GetComputedFields().FirstOrDefault(computedField => computedField.Key == key);

            if (computedFieldInfo != null && StatisticsProvider != null)
            {
                var mediaFileInfo = StatisticsProvider.GetFileData(PathToAnnotatedFile);
                if (mediaFileInfo != null)
                {
                    if (mediaFileInfo.Audio == null &&
                        PathToAnnotatedFile.EndsWith(Settings.Default.OralAnnotationGeneratedFileSuffix))
                    {
                        return("Not Generated");
                    }
                    // Get the computed value (if there is one).
                    computedValue = computedFieldInfo.GetFormatedStatProvider(
                        mediaFileInfo, computedFieldInfo.DataItemChooser, computedFieldInfo.Suffix);
                }
            }

            // Get the value from the metadata file.
            var field      = MetaDataFieldValues.FirstOrDefault(v => v.FieldId == key);
            var savedValue = (field == null ? defaultValue : field.ValueAsString);

            if (!string.IsNullOrEmpty(computedValue))
            {
                // If the computed value is different from the value found in the metadata
                // file, then save the computed value to the metadata file.
                if (computedValue != savedValue)
                {
                    // REVIEW: We probably don't want to save the formatted value to the
                    // metadata file, which is what we're doing here. In the future we'll
                    // probably want to change things to save the raw computed value.
                    SetStringValue(key, computedValue);
                    Save();
                    return(computedValue);
                }
            }

            return(savedValue);
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        public virtual object GetValue(string key, object defaultValue)
        {
            var field = MetaDataFieldValues.FirstOrDefault(v => v.FieldId == key);

            return(field == null ? defaultValue : field.Value);
        }