コード例 #1
0
        private MenuItemLayout CreateMenuItemLayout(IMenuItemProxy item,
                                                    int depth, int maxDepth,
                                                    string[] propertyNames)
        {
            var layout = new MenuItemLayout();

            layout.id         = mMenuItemList.IndexOf(item);
            layout.properties = new Dictionary <string, object>();
            foreach (var property in propertyNames)
            {
                try {
                    var value = item.GetValue(property);
                    if (!DefaultMenuItemProxy.IsDefaultValue(property, value))
                    {
                        layout.properties.Add(property, value);
                    }
                } catch (Exception ex) {
                    Debug.Fail(ex.ToString());
                }
            }
            var childList = new List <object>();

            if (maxDepth < 0 || depth < maxDepth)
            {
                foreach (var childItem in item.GetChildren())
                {
                    childList.Add(CreateMenuItemLayout(childItem, depth + 1,
                                                       maxDepth, propertyNames));
                }
            }
            layout.childeren = childList.ToArray();
            return(layout);
        }
コード例 #2
0
        public void GetLayout(int parentId, int recursionDepth, string[] propertyNames,
                              out uint revision, out MenuItemLayout layout)
        {
#if DEBUG
            Console.WriteLine("GetLayout - parentId:{0}, " +
                              "recursionDepth:{1}, propertyNames:{2}",
                              parentId, recursionDepth,
                              string.Join(", ", propertyNames));
#endif
            if (propertyNames.Length == 0)
            {
                propertyNames = DefaultMenuItemProxy.GetAllDisplayNames();
            }

            revision = mRevision;

            var item = mMenuItemList[parentId];
            layout = CreateMenuItemLayout(item, 0, recursionDepth, propertyNames);
        }