/// <summary>
        /// Compares the two instances and returns a value indicating their sort relation to each other.
        /// -1: obj1 is less than obj2
        /// 0: obj1 is equal to obj2
        /// 1: obj1 is greater than obj2
        /// </summary>
        /// <param name="obj1">One of the instances to compare.</param>
        /// <param name="obj2">One of the instances to compare.</param>
        /// <returns>Returns in integer indicating the objects' sort relation to each other.</returns>
        public int Compare(IGalleryObjectMetadataItem obj1, IGalleryObjectMetadataItem obj2)
        {
            if (obj1 == null)
            {
                // If obj1 is null and obj2 is null, they're equal.
                // If obj1 is null and obj2 is not null, obj2 is greater.
                return(obj2 == null ? 0 : -1);
            }
            else
            {
                if (obj2 == null)
                {
                    return(1);                    // obj1 is not null and obj2 is null, so obj1 is greater.
                }

                // Neither is null. Look up the display settings for each item and sort by its associated sequence property.
                IMetadataDefinition obj1MetadataDefinition = _metadataDisplayOptions.Find(obj1.MetadataItemName);
                IMetadataDefinition obj2MetadataDefinition = _metadataDisplayOptions.Find(obj2.MetadataItemName);

                if ((obj1MetadataDefinition != null) && (obj2MetadataDefinition != null))
                {
                    return(obj1MetadataDefinition.Sequence.CompareTo(obj2MetadataDefinition.Sequence));
                }
                else
                {
                    // Can't find one of the display settings. This should never occur because the IMetadataDefinitionCollection should
                    // have an entry for every value of the FormattedMetadataItemName enumeration.
                    throw new BusinessException(string.Format("The IMetadataDefinitionCollection instance passed to the GalleryObjectMetadataItemComparer constructor did not have an item corresponding to one of these FormattedMetadataItemName enum values: {0}, {1}. This collection should contain an item for every enum value.", obj1.MetadataItemName, obj2.MetadataItemName));
                }
            }
        }
 private ValidationResult ValidateMultiValue(string path, IMetadataDefinition definition, JToken token, JTokenType expectedType)
 {
     if (token.Type == JTokenType.Array)
     {
         var array = (JArray)token;
         int index = 0;
         foreach (var item in array)
         {
             if (item.Type != expectedType)
             {
                 return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedItemType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}[{index}], expected type '{expectedType.ToString()}'.", path);
             }
         }
         return ValidationResult.Success;
     }
     else if (token.Type == JTokenType.Null)
     {
         if (definition.IsRequired)
         {
             return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.FieldRequired, $"Bad metadata: property {path} is required.", path);
         }
         return ValidationResult.Success;
     }
     return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}, expected type '{nameof(JTokenType.Array)}'.", path);
 }
 private ValidationResult ValidateMultiValue(string path, IMetadataDefinition definition, JToken token, JTokenType expectedType)
 {
     if (token.Type == JTokenType.Array)
     {
         var array = (JArray)token;
         int index = 0;
         foreach (var item in array)
         {
             if (item.Type != expectedType)
             {
                 return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedItemType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}[{index}], expected type '{expectedType.ToString()}'.", path));
             }
         }
         return(ValidationResult.Success);
     }
     else if (token.Type == JTokenType.Null)
     {
         if (definition.IsRequired)
         {
             return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.FieldRequired, $"Bad metadata: property {path} is required.", path));
         }
         return(ValidationResult.Success);
     }
     return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}, expected type '{nameof(JTokenType.Array)}'.", path));
 }
Beispiel #4
0
 public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
 {
     if (definition.ChoiceSet == null)
     {
         return(ValidationResult.Success);
     }
     if (definition.IsMultiValued)
     {
         var array = value as JArray;
         if (array != null)
         {
             int index = 0;
             foreach (var item in array)
             {
                 var vr = ValidateOne($"{path}[{index}]", definition, item as JValue);
                 if (vr != ValidationResult.Success)
                 {
                     return(vr);
                 }
                 index++;
             }
         }
         return(ValidationResult.Success);
     }
     return(ValidateOne(path, definition, value as JValue));
 }
 public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
 {
     if (definition.ChoiceSet == null)
     {
         return ValidationResult.Success;
     }
     if (definition.IsMultiValued)
     {
         var array = value as JArray;
         if (array != null)
         {
             int index = 0;
             foreach (var item in array)
             {
                 var vr = ValidateOne($"{path}[{index}]", definition, item as JValue);
                 if (vr != ValidationResult.Success)
                 {
                     return vr;
                 }
                 index++;
             }
         }
         return ValidationResult.Success;
     }
     return ValidateOne(path, definition, value as JValue);
 }
 public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
 {
     switch (definition.Type)
     {
         case "string":
             if (definition.IsMultiValued)
             {
                 return ValidateMultiValue(path, definition, value, JTokenType.String);
             }
             return ValidateSimpleValue(path, definition, value, JTokenType.String);
         case "integer":
             if (definition.IsMultiValued)
             {
                 return ValidateMultiValue(path, definition, value, JTokenType.String);
             }
             return ValidateSimpleValue(path, definition, value, JTokenType.Integer);
         case "float":
             if (definition.IsMultiValued)
             {
                 return ValidateMultiValue(path, definition, value, JTokenType.String);
             }
             return ValidateSimpleValue(path, definition, value, JTokenType.Float);
         case "boolean":
             if (definition.IsMultiValued)
             {
                 return ValidateMultiValue(path, definition, value, JTokenType.String);
             }
             return ValidateSimpleValue(path, definition, value, JTokenType.Boolean);
         default:
             return ValidationResult.Fail(ValidationErrorCodes.Schema.BadSchema, $"Bad schema: unknown type '{definition.Type}' for property {path}.", path);
     }
 }
 private ValidationResult ValidateOne(string path, IMetadataDefinition definition, JValue value)
 {
     if (definition.ChoiceSet.Contains(value))
     {
         return ValidationResult.Success;
     }
     return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UndefinedValue, $"Bad metadata: Value {value.ToString()} is undefined for {path}.", path);
 }
Beispiel #8
0
 private ValidationResult ValidateOne(string path, IMetadataDefinition definition, JValue value)
 {
     if (definition.ChoiceSet.Contains(value))
     {
         return(ValidationResult.Success);
     }
     return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UndefinedValue, $"Bad metadata: Value {value.ToString()} is undefined for {path}.", path));
 }
        /// <summary>
        /// Gets a value indicating whether the specified <paramref name="metaDef" />
        /// applies to the current gallery object.
        /// </summary>
        /// <param name="metaDef">The metadata definition.</param>
        /// <returns><c>true</c> when the specified metadata item should be displayed; otherwise <c>false</c>.</returns>
        public override bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
        {
            switch (metaDef.MetadataItem)
            {
            case MetadataItemName.HtmlSource: return(false);

            default:
                return(base.MetadataDefinitionApplies(metaDef));
            }
        }
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
 /// </returns>
 public int CompareTo(IMetadataDefinition other)
 {
     if (other == null)
     {
         return(1);
     }
     else
     {
         return(Sequence.CompareTo(other.Sequence));
     }
 }
Beispiel #11
0
 public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
 {
     foreach (var v in Validators)
     {
         var result = v.Validate(path, definition, value);
         if (result != ValidationResult.Success)
         {
             return result;
         }
     }
     return ValidationResult.Success;
 }
Beispiel #12
0
 public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
 {
     foreach (var v in Validators)
     {
         var result = v.Validate(path, definition, value);
         if (result != ValidationResult.Success)
         {
             return(result);
         }
     }
     return(ValidationResult.Success);
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GalleryObjectMetadataItem" /> class.
 /// </summary>
 /// <param name="mediaObjectMetadataId">The value that uniquely indentifies this metadata item.</param>
 /// <param name="galleryObject">The gallery object this metadata item applies to.</param>
 /// <param name="rawValue">The raw value of the metadata item. Typically this is the value extracted from
 /// the metadata of the media file.</param>
 /// <param name="value">The value of the metadata item (e.g. "F5.7", "1/500 sec.").</param>
 /// <param name="hasChanges">if set to <c>true</c> this object has changes that have not been persisted to the database.</param>
 /// <param name="metaDef">The meta definition.</param>
 public GalleryObjectMetadataItem(int mediaObjectMetadataId, IGalleryObject galleryObject, string rawValue, string value, bool hasChanges, IMetadataDefinition metaDef)
 {
     _mediaObjectMetadataId = mediaObjectMetadataId;
     GalleryObject          = galleryObject;
     _metadataItemName      = metaDef.MetadataItem;
     _description           = metaDef.DisplayName;
     _rawValue      = rawValue;
     _value         = value;
     _hasChanges    = hasChanges;
     MetaDefinition = metaDef;
     _isVisible     = false;
     IsDeleted      = false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GalleryObjectMetadataItem" /> class.
 /// </summary>
 /// <param name="mediaObjectMetadataId">The value that uniquely indentifies this metadata item.</param>
 /// <param name="galleryObject">The gallery object this metadata item applies to.</param>
 /// <param name="rawValue">The raw value of the metadata item. Typically this is the value extracted from 
 /// the metadata of the media file.</param>
 /// <param name="value">The value of the metadata item (e.g. "F5.7", "1/500 sec.").</param>
 /// <param name="hasChanges">if set to <c>true</c> this object has changes that have not been persisted to the database.</param>
 /// <param name="metaDef">The meta definition.</param>
 public GalleryObjectMetadataItem(int mediaObjectMetadataId, IGalleryObject galleryObject, string rawValue, string value, bool hasChanges, IMetadataDefinition metaDef)
 {
     _mediaObjectMetadataId = mediaObjectMetadataId;
     GalleryObject = galleryObject;
     _metadataItemName = metaDef.MetadataItem;
     _description = metaDef.DisplayName;
     _rawValue = rawValue;
     _value = value;
     _hasChanges = hasChanges;
     MetaDefinition = metaDef;
     _isVisible = false;
     IsDeleted = false;
 }
        /// <summary>
        /// Apply the <paramref name="metadataDisplayOptions"/> to the items in the collection. This includes sorting the items and updating
        /// the <see cref="IGalleryObjectMetadataItem.IsVisible"/> property.
        /// </summary>
        /// <param name="metadataDisplayOptions">A collection of metadata definition items. Specify <see cref="IGallerySettings.MetadataDisplaySettings"/>
        /// for this parameter.</param>
        public void ApplyDisplayOptions(IMetadataDefinitionCollection metadataDisplayOptions)
        {
            // We know galleryObjectMetadataItems is actually a List<IGalleryObjectMetadataItem> because we passed it to the constructor.
            List <IGalleryObjectMetadataItem> galleryObjectMetadataItems = (List <IGalleryObjectMetadataItem>)Items;

            galleryObjectMetadataItems.Sort(new GalleryObjectMetadataItemComparer(metadataDisplayOptions));

            galleryObjectMetadataItems.ForEach(delegate(IGalleryObjectMetadataItem metaItem)
            {
                IMetadataDefinition metadataDef = metadataDisplayOptions.Find(metaItem.MetadataItemName);
                metaItem.IsVisible = metadataDef.IsVisible;
            });
        }
Beispiel #16
0
        private void UnbindMetadataDisplayOptions()
        {
            // 2|0|1|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|
            string[] metadataIds = Request.Form["gsp_seq"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string[] checkedIds  = Request.Form["gsp_chk"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            for (int seqIterator = 0; seqIterator < metadataIds.Length; seqIterator++)
            {
                string metadataId = metadataIds[seqIterator];
                IMetadataDefinition metadataDefinition = GallerySettingsUpdateable.MetadataDisplaySettings.Find((FormattedMetadataItemName)Convert.ToInt32(metadataId));
                metadataDefinition.Sequence  = seqIterator;
                metadataDefinition.IsVisible = (Array.IndexOf(checkedIds, metadataId) >= 0);
            }
        }
Beispiel #17
0
 private ValidationResult ValidateSimpleValue(string path, IMetadataDefinition definition, JToken token, JTokenType expectedType)
 {
     if (token.Type == expectedType)
     {
         return ValidationResult.Success;
     }
     if (token.Type == JTokenType.Null)
     {
         if (definition.IsRequired)
         {
             return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.FieldRequired, $"Bad metadata: property {path} is required.", path);
         }
         return ValidationResult.Success;
     }
     return ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}, expected type '{expectedType.ToString()}'.", path);
 }
Beispiel #18
0
 private ValidationResult ValidateSimpleValue(string path, IMetadataDefinition definition, JToken token, JTokenType expectedType)
 {
     if (token.Type == expectedType)
     {
         return(ValidationResult.Success);
     }
     if (token.Type == JTokenType.Null)
     {
         if (definition.IsRequired)
         {
             return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.FieldRequired, $"Bad metadata: property {path} is required.", path));
         }
         return(ValidationResult.Success);
     }
     return(ValidationResult.Fail(ValidationErrorCodes.WellknownMetadata.UnexpectedType, $"Bad metadata: unexpected type '{token.Type.ToString()}' for property {path}, expected type '{expectedType.ToString()}'.", path));
 }
Beispiel #19
0
        /// <summary>
        /// Apply the <paramref name="metadataDisplayOptions"/> to the items in the collection. This includes sorting the items and updating
        /// the <see cref="IGalleryObjectMetadataItem.IsVisible"/> property.
        /// </summary>
        /// <param name="metadataDisplayOptions">A collection of metadata definition items. Specify <see cref="IGallerySettings.MetadataDisplaySettings"/>
        /// for this parameter.</param>
        public void ApplyDisplayOptions(IMetadataDefinitionCollection metadataDisplayOptions)
        {
            // We know galleryObjectMetadataItems is actually a List<IGalleryObjectMetadataItem> because we passed it to the constructor.
            List <IGalleryObjectMetadataItem> galleryObjectMetadataItems = (List <IGalleryObjectMetadataItem>)Items;

            galleryObjectMetadataItems.Sort(new GalleryObjectMetadataItemComparer(metadataDisplayOptions));

            galleryObjectMetadataItems.ForEach(metaItem =>
            {
                IMetadataDefinition metadataDef = metadataDisplayOptions.Find(metaItem.MetadataItemName);

                if (metaItem.GalleryObject.GalleryObjectType == GalleryObjectType.Album)
                {
                    metaItem.IsVisible = metadataDef.IsVisibleForAlbum;
                }
                else
                {
                    metaItem.IsVisible = metadataDef.IsVisibleForGalleryObject;
                }
            });
        }
Beispiel #20
0
        public ValidationResult Validate(string path, IMetadataDefinition definition, JToken value)
        {
            switch (definition.Type)
            {
            case "string":
                if (definition.IsMultiValued)
                {
                    return(ValidateMultiValue(path, definition, value, JTokenType.String));
                }
                return(ValidateSimpleValue(path, definition, value, JTokenType.String));

            case "integer":
                if (definition.IsMultiValued)
                {
                    return(ValidateMultiValue(path, definition, value, JTokenType.String));
                }
                return(ValidateSimpleValue(path, definition, value, JTokenType.Integer));

            case "float":
                if (definition.IsMultiValued)
                {
                    return(ValidateMultiValue(path, definition, value, JTokenType.String));
                }
                return(ValidateSimpleValue(path, definition, value, JTokenType.Float));

            case "boolean":
                if (definition.IsMultiValued)
                {
                    return(ValidateMultiValue(path, definition, value, JTokenType.String));
                }
                return(ValidateSimpleValue(path, definition, value, JTokenType.Boolean));

            default:
                return(ValidationResult.Fail(ValidationErrorCodes.Schema.BadSchema, $"Bad schema: unknown type '{definition.Type}' for property {path}.", path));
            }
        }
        private static void StartRebuildMetaItem(IMetadataDefinition metaDef, IGalleryObject galleryObject, string userName)
        {
            try
            {
                AppEventController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO: Starting to rebuild metadata item '{0}' for all objects in gallery {1}.", metaDef.MetadataItem, galleryObject.GalleryId), galleryObject.GalleryId);

                RebuildMetaItem(metaDef, galleryObject, userName);

                HelperFunctions.PurgeCache();

                AppEventController.LogEvent(String.Format(CultureInfo.CurrentCulture, "INFO: Successfully finished rebuilding metadata item '{0}' for all objects in gallery {1}.", metaDef.MetadataItem, galleryObject.GalleryId), galleryObject.GalleryId);
            }
            catch (Exception ex)
            {
                AppEventController.LogError(ex, galleryObject.GalleryId);
                AppEventController.LogEvent(String.Format(CultureInfo.CurrentCulture, "CANCELLED: The rebuilding of metadata item '{0}' for all objects in gallery {1} has been cancelled due to the previously logged error.", metaDef.MetadataItem, galleryObject.GalleryId), galleryObject.GalleryId);
                throw;
            }
        }
        private static void RebuildMetaItem(IMetadataDefinition metaDef, IGalleryObject galleryObject, string userName)
        {
            galleryObject.ExtractMetadata(metaDef);

            IGalleryObjectMetadataItem metaItem;
            if (galleryObject.MetadataItems.TryGetMetadataItem(metaDef.MetadataItem, out metaItem))
            {
                Factory.SaveGalleryObjectMetadataItem(metaItem, userName);
            }

            if (galleryObject.GalleryObjectType == GalleryObjectType.Album)
            {
                foreach (var go in galleryObject.GetChildGalleryObjects())
                {
                    RebuildMetaItem(metaDef, go, userName);
                }
            }
        }
 public void ExtractMetadata(IMetadataDefinition metaDef)
 {
 }
 public bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
 {
     return false;
 }
Beispiel #25
0
		/// <summary>
		/// Create a new <see cref="IGalleryObjectMetadataItem" /> item from the specified parameters.
		/// </summary>
		/// <param name="id">A value that uniquely indentifies this metadata item.</param>
		/// <param name="galleryObject">The gallery object the metadata item applies to.</param>
		/// <param name="rawValue">The raw value of the metadata item. Typically this is the value extracted from 
		/// the metadata of the media file.</param>
		/// <param name="value">The value of the metadata item (e.g. "F5.7", "1/500 sec.").</param>
		/// <param name="hasChanges">A value indicating whether this metadata item has changes that have not been persisted to the database.</param>
		/// <param name="metaDef">The meta definition.</param>
		/// <returns>Returns a reference to the new item.</returns>
		public static IGalleryObjectMetadataItem CreateMetadataItem(int id, IGalleryObject galleryObject, string rawValue, string value, bool hasChanges, IMetadataDefinition metaDef)
		{
			return new GalleryObjectMetadataItem(id, galleryObject, rawValue, value, hasChanges, metaDef);
		}
 /// <summary>
 /// Creates a metadata item for the current gallery object. The parameter <paramref name="metaDef" />
 /// contains the template and display name to use. Guaranteed to not return null.
 /// </summary>
 /// <param name="metaDef">The metadata definition.</param>
 /// <returns>An instance of <see cref="IGalleryObjectMetadataItem" />.</returns>
 public IGalleryObjectMetadataItem CreateMetaItem(IMetadataDefinition metaDef)
 {
     return(Factory.CreateMetadataItem(int.MinValue, new NullGalleryObject(), null, String.Empty, false, new Metadata.MetadataDefinition(Metadata.MetadataItemName.AudioBitRate, String.Empty, false, false, PropertyEditorMode.NotSet, false, int.MinValue, String.Empty)));
 }
Beispiel #27
0
        public void ExtractMetadata(IMetadataDefinition metaDef)
        {
            if (MetadataDefinitionApplies(metaDef))
            {
                var metaItem = CreateMetaItem(metaDef);

                // Raise the BeforeAddMetaItem event.
                if (BeforeAddMetaItem != null)
                {
                    var args = new AddMetaEventArgs(metaItem);

                    BeforeAddMetaItem(this, args);

                    if (args.Cancel)
                    {
                        RemoveMetadataItem(metaDef.MetadataItem);
                        return;
                    }
                }

                // Add/update the item, but only when it is defined as being editable or has a value.
                if (metaItem.MetaDefinition.IsEditable || !String.IsNullOrWhiteSpace(metaItem.Value))
                    UpdateInternalMetaItem(metaItem);
                else if (Array.IndexOf(RequiredMetadataItems, metaDef.MetadataItem) < 0)
                    RemoveMetadataItem(metaDef.MetadataItem);
            }
            else
                RemoveMetadataItem(metaDef.MetadataItem);
        }
Beispiel #28
0
        /// <summary>
        /// Creates a metadata item for the current gallery object. The parameter <paramref name="metaDef" />
        /// contains the template and display name to use. Guaranteed to not return null.
        /// </summary>
        /// <param name="metaDef">The metadata definition.</param>
        /// <returns>An instance of <see cref="IGalleryObjectMetadataItem" />.</returns>
        public IGalleryObjectMetadataItem CreateMetaItem(IMetadataDefinition metaDef)
        {
            // Example: metaDef.DefaultValue = "Created at {DateCreated} - {Title}"
            // Loop through all token matches. For each one, extract the metavalue and replace the value. If there is only
            // one, use the raw value in the CreateMetadataItem line; otherwise use a null raw value.
            string rawValue = null;
            var formattedValue = metaDef.DefaultValue;
            var matches = MetaRegEx.Matches(metaDef.DefaultValue);

            foreach (Match match in matches)
            {
                var metaValue = ExtractMetaValue(match);

                if (metaValue != null)
                {
                    formattedValue = formattedValue.Replace(String.Concat("{", match.Groups[1].Value, "}"), metaValue.FormattedValue);
                    rawValue = metaValue.RawValue;
                }
                else
                {
                    formattedValue = formattedValue.Replace(String.Concat("{", match.Groups[1].Value, "}"), String.Empty);
                    rawValue = null;
                }
            }

            return Factory.CreateMetadataItem(int.MinValue, this, (matches.Count == 1 ? rawValue : null), formattedValue, true, metaDef);
        }
 /// <summary>
 /// Creates a metadata item for the current gallery object. The parameter <paramref name="metaDef" />
 /// contains the template and display name to use. Guaranteed to not return null.
 /// </summary>
 /// <param name="metaDef">The metadata definition.</param>
 /// <returns>An instance of <see cref="IGalleryObjectMetadataItem" />.</returns>
 public IGalleryObjectMetadataItem CreateMetaItem(IMetadataDefinition metaDef)
 {
     return Factory.CreateMetadataItem(int.MinValue, new NullGalleryObject(), null, String.Empty, false, new Metadata.MetadataDefinition(Metadata.MetadataItemName.AudioBitRate, String.Empty, false, false, false, int.MinValue, String.Empty));
 }
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
 /// </returns>
 public int CompareTo(IMetadataDefinition other)
 {
     if (other == null)
         return 1;
     else
     {
         return Sequence.CompareTo(other.Sequence);
     }
 }
Beispiel #31
0
 private static Type GetMetadataTypeCore(IMetadataDefinition definition)
 {
     switch (definition.Type)
     {
         case "string":
             return typeof(string);
         case "integer":
             return typeof(int);
         case "float":
             return typeof(double);
         case "boolean":
             return typeof(bool);
         default:
             throw new NotSupportedException(string.Format("Type '{0}' is not supported.", definition.Type));
     }
 }
Beispiel #32
0
 private Type GetMetadataType(IMetadataDefinition definition)
 {
     var result = GetMetadataTypeCore(definition);
     if (definition.IsMultiValued)
     {
         if (CollectionType == typeof(Array))
         {
             result = result.MakeArrayType();
         }
         else
         {
             result = CollectionType.MakeGenericType(result);
         }
     }
     else if (!definition.IsRequired && result.IsValueType)
     {
         result = typeof(Nullable<>).MakeGenericType(result);
     }
     return result;
 }
 public bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
 {
     return(false);
 }
 public void ExtractMetadata(IMetadataDefinition metaDef)
 {
 }
Beispiel #35
0
 /// <summary>
 /// Gets a value indicating whether the specified <paramref name="metaDef" />
 /// applies to the current gallery object.
 /// </summary>
 /// <param name="metaDef">The metadata definition.</param>
 /// <returns><c>true</c> when the specified metadata item should be displayed; otherwise <c>false</c>.</returns>
 public virtual bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
 {
     if (Array.IndexOf(RequiredMetadataItems, metaDef.MetadataItem) >= 0)
         return true; // We *ALWAYS* want to create certain items (such as Title and Caption).
     else
         return Factory.LoadGallerySetting(GalleryId).ExtractMetadata && metaDef.IsVisibleForGalleryObject;
 }
Beispiel #36
0
 /// <summary>
 /// Gets a value indicating whether the specified <paramref name="metaDef" />
 /// applies to the current gallery object.
 /// </summary>
 /// <param name="metaDef">The metadata definition.</param>
 /// <returns><c>true</c> when the specified metadata item should be displayed; otherwise <c>false</c>.</returns>
 public override bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
 {
     switch (metaDef.MetadataItem)
     {
         case MetadataItemName.HtmlSource: return false;
         default:
             return base.MetadataDefinitionApplies(metaDef);
     }
 }
Beispiel #37
0
 /// <summary>
 /// Gets a value indicating whether the administrator has indicated the specified <paramref name="metaDef" />
 /// applies to the current gallery object.
 /// </summary>
 /// <param name="metaDef">The metadata definition.</param>
 /// <returns><c>true</c> when the specified metadata item should be displayed; otherwise <c>false</c>.</returns>
 public override bool MetadataDefinitionApplies(IMetadataDefinition metaDef)
 {
     if (metaDef.MetadataItem == MetadataItemName.Title || metaDef.MetadataItem == MetadataItemName.Caption)
         return true; // We *ALWAYS* want to create a Title and Caption item.
     else
         return metaDef.IsVisibleForAlbum;
 }