Esempio n. 1
0
        public static void InitContentGet(IContentService service, IContentTypeService typeService)
        {
            AllContentByType    = UmbracoContentExtend.GetAllContentTypeFunction(typeService, service);
            ContentValueString  = UmbracoContentExtend.GetContentValue <string>(service);
            ContentValueInt     = UmbracoContentExtend.GetContentValue <int>(service);
            ContentValueDecimal = UmbracoContentExtend.GetContentValue <decimal>(service);
            ContentValueBool    = UmbracoContentExtend.GetContentValue <bool>(service);
            ContentValueDate    = UmbracoContentExtend.GetContentValue <DateTime?>(service);
            GetIContentById     = (int id, bool?alive) => UmbracoContentExtend.GetContent(service)(id, alive);
            Func <int, string, bool?, IContent> GetIContentFunc = (id, key, alive) => GetIContentById(id, alive);

            ContentValueFuncMap = new Dictionary <Type, dynamic>()
            {
                [typeof(string)]    = ContentValueString,
                [typeof(int)]       = ContentValueInt,
                [typeof(decimal)]   = ContentValueDecimal,
                [typeof(string)]    = ContentValueString,
                [typeof(bool)]      = ContentValueBool,
                [typeof(DateTime?)] = ContentValueDate,
                [typeof(IContent)]  = GetIContentFunc
            };

            GetHomePage               = () => UmbracoContentExtend.GetContent(service)(E.Config[EnvironmentKey.HomeId], true);
            GetBreadCrumbById         = id => UmbracoContentExtend.GetBreadCrumbFunction(id, b => GetIContentById(b, null));
            GetIContentByIds          = (ids, alive) => UmbracoContentExtend.GetContentsByIds(service, ids, alive: alive);
            GetChildContentById       = (rootId, where, alive) => UmbracoContentExtend.GetContentsByIds(service, rootId: rootId, alive: alive, where : where);
            ViewTempAndContent.Helper = E.GetHelper;
        }
Esempio n. 2
0
        public static void InitContentGet()
        {
            AllContentByType    = (type) => E.MyGetIContentsByType(type, null, null, $"get all type {type}");
            ContentValueString  = (id, key, alive) => E.MyGetContentByid(id).GetValueNull <string>(key);
            ContentValueInt     = (id, key, alive) => E.MyGetContentByid(id).GetValueNull <int>(key);
            ContentValueDecimal = (id, key, alive) => E.MyGetContentByid(id).GetValueNull <decimal>(key);
            ContentValueBool    = (id, key, alive) => E.MyGetContentByid(id).GetValueNull <bool>(key);
            ContentValueDate    = (id, key, alive) => E.MyGetContentByid(id).GetValueNull <DateTime?>(key);
            GetIContentById     = (id, alive) => E.MyGetContentByid(id);
            Func <int, string, bool?, IContent> GetIContentFunc = (id, key, alive) => GetIContentById(id, alive);

            ContentValueFuncMap = new Dictionary <Type, dynamic>()
            {
                [typeof(string)]    = ContentValueString,
                [typeof(int)]       = ContentValueInt,
                [typeof(decimal)]   = ContentValueDecimal,
                [typeof(string)]    = ContentValueString,
                [typeof(bool)]      = ContentValueBool,
                [typeof(DateTime?)] = ContentValueDate,
                [typeof(IContent)]  = GetIContentFunc
            };

            GetHomePage               = () => E.GetIContentById(E.Config[EnvironmentKey.HomeId], true);
            GetBreadCrumbById         = id => UmbracoContentExtend.GetBreadCrumbFunction(id, b => GetIContentById(b, null));
            GetIContentByIds          = (ids, alive) => E.MyGetContentsByIds(ids, null, alive, $"get ids {String.Join(",", ids)}");
            GetChildContentById       = (rootId, where, alive) => E.MyGetChildByRootId(rootId, where, alive, $"get child {rootId}");
            ViewTempAndContent.Helper = E.GetHelper;
        }
Esempio n. 3
0
 public static void init(int homeID, CaltureType calture)
 {
     Config = new Dictionary <EnvKey, dynamic>()
     {
         [EnvKey.HomeId] = homeID
     };
     Services = ApplicationContext.Current.Services;
     Calture  = new CaltureService();
     Calture.DefaultCalture = calture;
     AllContentByType       = UmbracoContentExtend.GetAllContentTypeFunction(Services.ContentTypeService, Services.ContentService);
     ContentValueString     = UmbracoContentExtend.GetContentValue <string>(Services.ContentService);
     ContentValueInt        = UmbracoContentExtend.GetContentValue <int>(Services.ContentService);
     ContentValueBool       = UmbracoContentExtend.GetContentValue <bool>(Services.ContentService);
 }