コード例 #1
0
        /// <summary>
        /// Read from a class and write the data to an item. Ensure item is in editing state before calling.
        /// </summary>
        /// <typeparam name="T">The type of the class to read from.</typeparam>
        /// <param name="content">The content.</param>
        /// <param name="target">The class to read from</param>
        public static void GlassRead <T>(this IContent content, T target) where T : class
        {
            IUmbracoService service = new UmbracoService(new ContentService());

            service.WriteToItem(target, content);
        }
コード例 #2
0
        /// <summary>
        /// Casts and item to a strongly typed. Uses the default Context to load types.
        /// </summary>
        /// <typeparam name="T">Type to return</typeparam>
        /// <param name="content">The content.</param>
        /// <param name="isLazy">if set to <c>true</c> [is lazy].</param>
        /// <param name="inferType">if set to <c>true</c> [infer type].</param>
        /// <returns>
        /// A strongly typed class representation of the item
        /// </returns>
        public static T GlassCast <T>(this IContent content, bool isLazy = false, bool inferType = false) where T : class
        {
            var service = new UmbracoService(new ContentService());

            return(content.GlassCast <T>(service, isLazy, inferType));
        }