コード例 #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();
        }
コード例 #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();
        }
コード例 #3
0
        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 + "]");
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 private void Initialize()
 {
     _attribute = GetType().GetTreeAttribute();
 }
コード例 #6
0
 protected TreeController()
 {
     _treeAttribute = GetTreeAttribute();
 }
コード例 #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();
 }