Пример #1
0
        public static string GetFormattedBreadCrumb(this DiyGroup group,
            IDiyService diyService,
            string separator = ">>")
        {
            if (group == null)
                throw new ArgumentNullException("group");

            string result = string.Empty;

            //used to prevent circular references
            var alreadyProcessedDiyGroupIds = new List<int>() { };

            while (group != null &&  //not null
                !group.Deleted &&  //not deleted
                !alreadyProcessedDiyGroupIds.Contains(group.Id)) //prevent circular references
            {
                if (String.IsNullOrEmpty(result))
                {
                    result = group.Name;
                }
                else
                {
                    result = string.Format("{0} {1} {2}", group.Name, separator, result);
                }

                alreadyProcessedDiyGroupIds.Add(group.Id);

                group = diyService.GetDiyGroupById(group.ParentGroupId);

            }
            return result;
        }
Пример #2
0
        public static IList<DiyGroup> GetDiyGroupBreadCrumb(this DiyGroup diyGroup,
            IDiyService diyService,
            bool showHidden = false)
        {
            if (diyGroup == null)
                throw new ArgumentNullException("diyGroup");

            var result = new List<DiyGroup>();

            //used to prevent circular references
            var alreadyProcessedDiyGroupIds = new List<int>() { };

            while (diyGroup != null && //not null
                !diyGroup.Deleted && //not deleted
                !alreadyProcessedDiyGroupIds.Contains(diyGroup.Id)) //prevent circular references
            {
                result.Add(diyGroup);

                alreadyProcessedDiyGroupIds.Add(diyGroup.Id);

                diyGroup = diyService.GetDiyGroupById(diyGroup.ParentGroupId);
            }
            result.Reverse();
            return result;
        }