/// <summary>
        /// Maps data from the CMS value to the .Net property value
        /// </summary>
        /// <param name="mappingContext">The mapping context.</param>
        /// <returns>System.Object.</returns>
        public override object MapToProperty(AbstractDataMappingContext mappingContext)
        {
            var scContext = mappingContext as SitecoreDataMappingContext;
            var scConfig = Configuration as SitecoreChildrenConfiguration;

            Func<IEnumerable<Item>> getItems = () =>
                ItemManager.GetChildren(scContext.Item, SecurityCheck.Enable, ChildListOptions.None);

            if (_activator == null)
            {
                _activator = Mapper.Utilities.GetActivator(
                    typeof (LazyItemEnumerable<>),
                    new[] {GenericType},
                    getItems,
                    scConfig.IsLazy,
                    scConfig.InferType,
                    scContext.Service);
            }

            return _activator(getItems,
                scConfig.IsLazy,
                scConfig.InferType,
                scContext.Service);

        }
Example #2
0
        /// <summary>
        /// Maps data from the CMS value to the .Net property value
        /// </summary>
        /// <param name="mappingContext">The mapping context.</param>
        /// <returns>System.Object.</returns>
        public override object MapToProperty(AbstractDataMappingContext mappingContext)
        {
            var scContext = mappingContext as SitecoreDataMappingContext;
            var scConfig  = Configuration as SitecoreChildrenConfiguration;

            Func <IEnumerable <Item> > getItems = () =>
                                                  ItemManager.GetChildren(scContext.Item, SecurityCheck.Enable, ChildListOptions.None);

            if (_activator == null)
            {
                _activator = Mapper.Utilities.GetActivator(
                    typeof(LazyItemEnumerable <>),
                    new[] { GenericType },
                    getItems,
                    scConfig.IsLazy,
                    scConfig.InferType,
                    scContext.Service);
            }

            return(_activator(getItems,
                              scConfig.IsLazy,
                              scConfig.InferType,
                              scContext.Service));
        }