Esempio n. 1
0
        private void Initialize()
        {
            //Locate the tree attribute
            var treeAttributes = GetType()
                                 .GetCustomAttributes(typeof(TreeAttribute), false)
                                 .OfType <TreeAttribute>()
                                 .ToArray();

            if (treeAttributes.Any() == false)
            {
                throw new InvalidOperationException("The Tree controller is missing the " + typeof(TreeAttribute).FullName + " attribute");
            }

            //assign the properties of this object to those of the metadata attribute
            _attribute = treeAttributes.First();
        }
Esempio n. 2
0
        protected TreeController()
        {
            //Locate the tree attribute
            var treeAttributes = GetType()
                .GetCustomAttributes(typeof(TreeAttribute), false)
                .OfType<TreeAttribute>()
                .ToArray();

            if (treeAttributes.Any() == false)
            {
                throw new InvalidOperationException("The Tree controller is missing the " + typeof(TreeAttribute).FullName + " attribute");
            }

            //assign the properties of this object to those of the metadata attribute
            _attribute = treeAttributes.First();
        }
        internal static string GetRootNodeDisplayName(this TreeAttribute attribute, ILocalizedTextService textService)
        {
            //if title is defined, return that
            if (string.IsNullOrEmpty(attribute.Title) == false)
            {
                return(attribute.Title);
            }


            //try to look up a tree header matching the tree alias
            var localizedLabel = textService.Localize("treeHeaders/" + attribute.Alias);

            if (string.IsNullOrEmpty(localizedLabel) == false)
            {
                return(localizedLabel);
            }

            //is returned to signal that a label was not found
            return("[" + attribute.Alias + "]");
        }
        internal static string GetRootNodeDisplayName(this TreeAttribute attribute, ILocalizedTextService textService)
        {
            var label = $"[{attribute.Alias}]";

            // try to look up a the localized tree header matching the tree alias
            var localizedLabel = textService.Localize("treeHeaders/" + attribute.Alias);

            // if the localizedLabel returns [alias] then return the title attribute from the trees.config file, if it's defined
            if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
            {
                if (string.IsNullOrEmpty(attribute.Title) == false)
                {
                    label = attribute.Title;
                }
            }
            else
            {
                // the localizedLabel translated into something that's not just [alias], so use the translation
                label = localizedLabel;
            }

            return(label);
        }
 private void Initialize()
 {
     _attribute = GetType().GetTreeAttribute();
 }
Esempio n. 6
0
 protected TreeController()
 {
     _treeAttribute = GetTreeAttribute();
 }
Esempio n. 7
0
 protected TreeController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
     : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
 {
     _treeAttribute = GetTreeAttribute();
 }