コード例 #1
0
        public CategoryCached(Category category)
        {
            Id                          = category.Id;
            Name                        = category.Name;
            NameNormalized              = category.NameNormalized;
            Token                       = category.Token ?? category.Name.ToLower();
            AppendTokenToSubCatsPath    = category.AppendTokenToSubCatsPath;
            ShowInBreadcrumbs           = category.ShowInBreadcrumbs;
            Title                       = category.Title;
            IsMaterialsContainer        = category.IsMaterialsContainer;
            SubTitle                    = category.SubTitle;
            Icon                        = category.Icon;
            Header                      = category.Header;
            IsMaterialsNameEditable     = category.IsMaterialsNameEditable;
            IsMaterialsSubTitleEditable = category.IsMaterialsSubTitleEditable;
            SettingsJson                = SunJson.MakeJElement(category.SettingsJson);
            ParentId                    = category.ParentId;
            SortNumber                  = category.SortNumber;
            LayoutName                  = category.LayoutName;
            IsHidden                    = category.IsHidden;
            IsCacheContent              = category.IsCacheContent;

            _subCategories    = new List <CategoryCached>();
            _allSubCategories = new List <CategoryCached>();
        }
コード例 #2
0
        public SectionClientCached(Section section, Dictionary <string, Type> clientComponentTypes,
                                   IRolesCache rolesCache)
        {
            Id   = section.Id;
            Name = section.Name;
            Type = section.Type;
            if (section.Roles != null)
            {
                Roles = section.Roles.Split(',')
                        .Select(x => rolesCache.GetRole(x))
                        .ToDictionary(x => x.Id, x => x)
                        .ToImmutableDictionary();
            }
            else
            {
                Roles = new Dictionary <int, RoleCached>().ToImmutableDictionary();
            }

            if (clientComponentTypes.TryGetValue(Type, out Type type))
            {
                object clientData = JsonSerializer.Deserialize(section.Options, type);
                string clientJson = JsonSerializer.Serialize(clientData);
                Options = SunJson.MakeJElement(clientJson);
            }
        }
コード例 #3
0
 public ComponentClientCached(Component component, IReadOnlyDictionary <int, RoleCached> roles)
 {
     Id       = component.Id;
     Name     = component.Name;
     Type     = component.Type;
     Settings = SunJson.MakeJElement(component.ClientSettingsJson);
     Roles    = roles;
 }
コード例 #4
0
        public MenuItemCached(MenuItem menuItem, IReadOnlyDictionary <int, RoleCached> roles)
        {
            Id          = menuItem.Id;
            ParentId    = menuItem.ParentId;
            Name        = menuItem.Name;
            Title       = menuItem.Title;
            SubTitle    = menuItem.SubTitle;
            RouteName   = menuItem.RouteName;
            Exact       = menuItem.Exact;
            CssClass    = menuItem.CssClass;
            ExternalUrl = menuItem.ExternalUrl;
            IsSeparator = menuItem.IsSeparator;
            SortNumber  = menuItem.SortNumber;
            Icon        = menuItem.Icon;
            IsHidden    = menuItem.IsHidden;

            RouteParamsJson = SunJson.MakeJElement(menuItem.RouteParamsJson);
            SettingsJson    = SunJson.MakeJElement(menuItem.SettingsJson);

            Roles = roles;
        }