示例#1
0
        /// <summary>
        /// Convenience method to set a collection attribute in a dictionary of media item aspectData. If the given <paramref name="aspectData"/>
        /// dictionary contains the media item aspect of the requested aspect type, that aspect instance is used to store the
        /// attribute corresponding to the given <paramref name="attributeSpecification"/>. If the corresponding aspect instance is not
        /// present in the dictionary yet, it is created and added to the dictionary before setting the value.
        /// </summary>
        /// <param name="aspectData">Dictionary of aspect data to be written to.</param>
        /// <param name="attributeSpecification">Type of the attribute to write.</param>
        /// <param name="value">Value to be set.</param>
        public static void SetCollectionAttribute <T>(IDictionary <Guid, IList <MediaItemAspect> > aspectData,
                                                      MediaItemAspectMetadata.SingleAttributeSpecification attributeSpecification, IEnumerable <T> value)
        {
            SingleMediaItemAspect aspect = GetOrCreateAspect(aspectData, attributeSpecification.ParentMIAM);

            aspect.SetCollectionAttribute(attributeSpecification, value);
        }
示例#2
0
 public RelationshipType(string name, bool isPrimaryParent,
                         Guid childRole, Guid parentRole,
                         Guid childAspectId, Guid parentAspectId,
                         MediaItemAspectMetadata.AttributeSpecification childCountAttribute, MediaItemAspectMetadata.SingleAttributeSpecification parentCountAttribute,
                         bool updatePlayPercentage)
 {
     Name                 = name;
     IsPrimaryParent      = isPrimaryParent;
     ChildAspectId        = childAspectId;
     ParentAspectId       = parentAspectId;
     ChildRole            = childRole;
     ParentRole           = parentRole;
     ChildCountAttribute  = childCountAttribute;
     ParentCountAttribute = parentCountAttribute;
     UpdatePlayPercentage = updatePlayPercentage;
 }
示例#3
0
        /// <summary>
        /// Convenience method to get a simple attribute in a dictionary of media item aspectData.
        /// </summary>
        /// <typeparam name="TE">Type parameter.</typeparam>
        /// <param name="aspectData">Dictionary of aspect data to be read from.</param>
        /// <param name="attributeSpecification">Type of the attribute to read.</param>
        /// <param name="defaultValue">If the attribute is {null} this value will be returned.</param>
        /// <param name="value">Returns the value.</param>
        /// <returns><c>true</c> if value exists or a null value was substituted by <paramref name="defaultValue"/>.</returns>
        public static bool TryGetAttribute <TE>(IDictionary <Guid, IList <MediaItemAspect> > aspectData,
                                                MediaItemAspectMetadata.SingleAttributeSpecification attributeSpecification, TE defaultValue, out TE value)
        {
            value = default(TE);
            SingleMediaItemAspect         mediaAspect;
            SingleMediaItemAspectMetadata metadata = attributeSpecification.ParentMIAM;

            if (!TryGetAspect(aspectData, metadata, out mediaAspect))
            {
                return(false);
            }

            object attribute = mediaAspect[attributeSpecification] ?? defaultValue;

            value = (TE)attribute;
            return(true);
        }