コード例 #1
0
        /// <summary>
        /// Called after a metadata item has been created for an object but before it has been added to
        /// the <see cref="IGalleryObject.MetadataItems" /> collection.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="AddMetaEventArgs" /> instance containing the event data.</param>
        private void OnBeforeAddMetaItem(object sender, AddMetaEventArgs e)
        {
            switch (e.MetaItem.MetadataItemName)
            {
                case MetadataItemName.GpsLocationWithMapLink:
                    if (MetadataReadWriter.GetMetaValue(MetadataItemName.GpsLocation) == null)
                    {
                        e.MetaItem.Value = String.Empty;
                    }
                    break;

                case MetadataItemName.GpsDestLocationWithMapLink:
                    if (MetadataReadWriter.GetMetaValue(MetadataItemName.GpsDestLocation) == null)
                    {
                        e.MetaItem.Value = String.Empty;
                    }
                    break;
            }
        }
コード例 #2
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);
        }