コード例 #1
0
        public static IEnumerable <dynamic> SelectedMedia(this TypedAttribute attribute, bool includeUnpublished, bool includeRecycled)
        {
            //BUG: we are returning content currently since there is no AsDynamic method for Media.
            // this should still work but may cause problems if people try to access content specific stuff dynamically.
            // http://issues.rebelcms.com/issue/U5-959
            // Also, because of this we cannot validate the media tree type!!

            return(GetItems <Content, IContentStore>(attribute.SelectedNodeIds().ToArray(), includeUnpublished, includeRecycled, FixedHiveIds.MediaRecylceBin)
                   .AsDynamic());
        }
コード例 #2
0
        /// <summary>
        /// Returns the items for either the requested Media or Content
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TStore"></typeparam>
        /// <param name="attribute"></param>
        /// <param name="nodeSelector"></param>
        /// <param name="treeId"></param>
        /// <param name="errMsg"></param>
        /// <param name="includeUnpublished"></param>
        /// <param name="includeRecycled"></param>
        /// <param name="recycleBinId"></param>
        /// <returns></returns>
        private static IEnumerable <T> GetItemsWithValidation <T, TStore>(
            TypedAttribute attribute,
            NodeSelectorEditor nodeSelector,
            Guid treeId,
            Func <string> errMsg,
            bool includeUnpublished,
            bool includeRecycled,
            HiveId recycleBinId)
            where T : TypedEntity
            where TStore : class, IProviderTypeFilter
        {
            var preVals = nodeSelector.CreatePreValueEditorModel();

            preVals.SetModelValues(attribute.AttributeDefinition.AttributeType.RenderTypeProviderConfig);
            //now we can check if it is set to a content tree
            if (preVals.SelectedTree != treeId)
            {
                throw new InvalidOperationException(errMsg());
            }

            return(GetItems <T, TStore>(attribute.SelectedNodeIds().ToArray(), includeUnpublished, includeRecycled, recycleBinId));
        }