Beispiel #1
0
        /// <summary>
        /// Adds GPS location URL metadata item to the <see cref="IGalleryObject.MetadataItems" />
        /// collection of <paramref name="galleryObject" />. If the gallery object's metadata does not contain GPS data or the
        /// visibility of the GPS map link is turned off, no action is taken.
        /// </summary>
        /// <param name="galleryObject">The gallery object.</param>
        /// <param name="metadataDisplaySettings">The metadata display settings.</param>
        /// <remarks>The metadata item is added with <see cref="IGalleryObjectMetadataItem.HasChanges" /> = <c>false</c> to prevent it
        /// from getting persisted to the database. This allows the hyperlink to be regenerated from the template, thus incorporating the
        /// most recent template and other media object properties (such as title). Because the item is linked to the media object, it is
        /// automatically included in the cache of media objects.
        /// This function is identical to <see cref="AddGpsDestLocationWithMapLink" /> except it uses the destination GPS settings.</remarks>
        private static void AddGpsLocationWithMapLink(IGalleryObject galleryObject, IMetadataDefinitionCollection metadataDisplaySettings)
        {
            if (!metadataDisplaySettings.Find(FormattedMetadataItemName.GpsLocationWithMapLink).IsVisible)
            {
                return;                 // The map link is disabled, so there is nothing to do.
            }
            IGalleryObjectMetadataItemCollection metadata = galleryObject.MetadataItems;
            IGalleryObjectMetadataItem           gpsLocation;

            if (metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLocation, out gpsLocation) && (!metadata.Contains(FormattedMetadataItemName.GpsLocationWithMapLink)))
            {
                // We have a GPS location but have not yet created the URL'd version. Do so now and add it to the collection.
                IGalleryObjectMetadataItem latitude;
                IGalleryObjectMetadataItem longitude;
                bool foundLatitude  = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLatitude, out latitude);
                bool foundLongitude = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLongitude, out longitude);

                if (foundLatitude && foundLongitude)
                {
                    string url = GetGpsMapUrl(galleryObject, latitude.Value, longitude.Value, gpsLocation.Value);

                    if (!String.IsNullOrEmpty(url))
                    {
                        // Add to meta collection. Specify false for HasChanges to prevent it from getting persisted back to the database.
                        galleryObject.MetadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsLocationWithMapLink, Resources.GalleryServerPro.Metadata_GpsLocationWithMapLink, url, false);
                    }
                }
            }
        }
 private void CheckCustomAttributes()
 {
     if (this._metadata == null)
     {
         this._metadata = new MetadataDefinitionCollection(this, this.Assembly);
     }
 }
Beispiel #3
0
 public override void Dispose()
 {
     try
     {
         lock (this.SyncObject)
         {
             if (this.metadata != null)
             {
                 this.metadata.Dispose();
                 this.metadata = null;
             }
             if (this.constraints != null)
             {
                 this.constraints.Clear();
                 this.constraints = null;
             }
             if (this._constraints != null)
             {
                 this._constraints.Dispose();
                 this._constraints = null;
             }
             if (this.constructors != null)
             {
                 this.constructors.Dispose();
                 this.constructors = null;
             }
             if (this.events != null)
             {
                 this.events.Dispose();
                 this.events = null;
             }
             if (this.indexers != null)
             {
                 this.indexers.Dispose();
                 this.indexers = null;
             }
             if (this.methods != null)
             {
                 this.methods.Dispose();
                 this.methods = null;
             }
             if (this.properties != null)
             {
                 this.properties.Dispose();
                 this.properties = null;
             }
             if (this._members != null)
             {
                 this._members.Dispose();
                 this._members = null;
             }
         }
     }
     finally
     {
         base.Dispose();
     }
 }
        /// <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 #5
0
        /// <summary>
        /// Handles the <see cref="GalleryObject.MetadataLoaded" /> event of the <see cref="GalleryObject" /> class. Specifically, it
        /// adds run-time metadata items such as GPS location map URLs. It also sorts the metadata items.
        /// </summary>
        /// <param name="sender">The source of the event. Should always be an instance of <see cref="IGalleryObject" />.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private static void GalleryObjectMetadataLoaded(object sender, EventArgs e)
        {
            IGalleryObject galleryObject = sender as IGalleryObject;

            if (galleryObject == null)
            {
                return;
            }

            IMetadataDefinitionCollection metadataDisplayOptions = Factory.LoadGallerySetting(galleryObject.GalleryId).MetadataDisplaySettings;

            AddGpsLocationWithMapLink(galleryObject, metadataDisplayOptions);

            AddGpsDestLocationWithMapLink(galleryObject, metadataDisplayOptions);

            galleryObject.MetadataItems.ApplyDisplayOptions(metadataDisplayOptions);
        }
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (this.uniqueIdentifier != null)
         {
             this.uniqueIdentifier = null;
         }
         if (this.metadata != null)
         {
             this.metadata = null;
         }
         if (this.canRead)
         {
             this.canRead = false;
         }
         if (this.getMethod != null)
         {
             this.getMethod.Dispose();
             this.getMethod = null;
         }
         if (this.canWrite)
         {
             this.canWrite = false;
         }
         if (this.setMethod != null)
         {
             this.setMethod.Dispose();
             this.setMethod = null;
         }
         if (this.implementationTypes != null)
         {
             this.implementationTypes.Dispose();
             this.implementationTypes.Clear();
             this.implementationTypes = null;
         }
         this.propertyType = null;
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
 public override void Dispose()
 {
     try
     {
         if (this._metadata != null)
         {
             this._metadata.Dispose();
             this._metadata = null;
         }
         this.parent          = null;
         this.name            = null;
         this.declaringModule = null;
     }
     finally
     {
         this.isDisposed = 1;
         base.Dispose();
     }
 }
Beispiel #8
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;
                }
            });
        }
 protected override void Dispose(bool disposing)
 {
     try
     {
         lock (this.SyncObject)
         {
             if (this.uniqueIdentifier != null)
             {
                 this.uniqueIdentifier = null;
             }
             if (this.metadata != null)
             {
                 this.metadata = null;
             }
             if (this.canRead)
             {
                 this.canRead = false;
             }
             if (this.getMethod != null)
             {
                 this.getMethod.Dispose();
                 this.getMethod = null;
             }
             if (this.canWrite)
             {
                 this.canWrite = false;
             }
             if (this.setMethod != null)
             {
                 this.setMethod.Dispose();
                 this.setMethod = null;
             }
             this.propertyType = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
        /// <summary>
        /// Adds GPS location URL metadata item to the <see cref="IGalleryObject.MetadataItems" />
        /// collection of <paramref name="galleryObject" />. If the gallery object's metadata does not contain GPS data or the
        /// visibility of the GPS map link is turned off, no action is taken.
        /// </summary>
        /// <param name="galleryObject">The gallery object.</param>
        /// <param name="metadataDisplaySettings">The metadata display settings.</param>
        /// <remarks>The metadata item is added with <see cref="IGalleryObjectMetadataItem.HasChanges" /> = <c>false</c> to prevent it 
        /// from getting persisted to the database. This allows the hyperlink to be regenerated from the template, thus incorporating the
        /// most recent template and other media object properties (such as title). Because the item is linked to the media object, it is
        /// automatically included in the cache of media objects.
        /// This function is identical to <see cref="AddGpsDestLocationWithMapLink" /> except it uses the destination GPS settings.</remarks>
        private static void AddGpsLocationWithMapLink(IGalleryObject galleryObject, IMetadataDefinitionCollection metadataDisplaySettings)
        {
            if (!metadataDisplaySettings.Find(FormattedMetadataItemName.GpsLocationWithMapLink).IsVisible)
                return; // The map link is disabled, so there is nothing to do.

            IGalleryObjectMetadataItemCollection metadata = galleryObject.MetadataItems;
            IGalleryObjectMetadataItem gpsLocation;

            if (metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLocation, out gpsLocation) && (!metadata.Contains(FormattedMetadataItemName.GpsLocationWithMapLink)))
            {
                // We have a GPS location but have not yet created the URL'd version. Do so now and add it to the collection.
                IGalleryObjectMetadataItem latitude;
                IGalleryObjectMetadataItem longitude;
                bool foundLatitude = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLatitude, out latitude);
                bool foundLongitude = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsLongitude, out longitude);

                if (foundLatitude && foundLongitude)
                {
                    string url = GetGpsMapUrl(galleryObject, latitude.Value, longitude.Value, gpsLocation.Value);

                    if (!String.IsNullOrEmpty(url))
                    {
                        // Add to meta collection. Specify false for HasChanges to prevent it from getting persisted back to the database.
                        galleryObject.MetadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsLocationWithMapLink, Resources.GalleryServerPro.Metadata_GpsLocationWithMapLink, url, false);
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GalleryObjectMetadataItemComparer"/> class. The items are compared using
 /// the <see cref="IMetadataDefinition.Sequence" /> property of the <paramref name="metadataDisplayOptions" /> parameter.
 /// </summary>
 /// <param name="metadataDisplayOptions">The metadata display options.</param>
 public GalleryObjectMetadataItemComparer(IMetadataDefinitionCollection metadataDisplayOptions)
 {
     _metadataDisplayOptions = metadataDisplayOptions;
 }