private void RecursiveDataBindInternal(IHierarchicalEnumerable enumerable, StringBuilder sb)
        {
            bool first = true;

            if (this.Site != null)
            {
                return;
            }
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);
                if (null != data)
                {
                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
                    if (props.Count > 0)
                    {
                        string title       = ((string)(props["Title"].GetValue(data)));
                        string description = ((string)(props["Description"].GetValue(data)));
                        string url         = ((string)(props["Url"].GetValue(data)));
                        string cssClass    = null;
                        if (item is SiteMapNode)
                        {
                            cssClass = ((SiteMapNode)(item))["cssClass"];
                        }
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            sb.Append(",");
                        }
                        sb.AppendFormat("{{\'title\':\'{0}\',\'url\':\'{1}\'", BusinessRules.JavaScriptString(title), BusinessRules.JavaScriptString(url));
                        if (!(String.IsNullOrEmpty(description)))
                        {
                            sb.AppendFormat(",\'description\':\'{0}\'", BusinessRules.JavaScriptString(description));
                        }
                        if (url == Page.Request.RawUrl)
                        {
                            sb.Append(",\'selected\':true");
                        }
                        if (!(String.IsNullOrEmpty(cssClass)))
                        {
                            sb.AppendFormat(",\'cssClass\':\'{0}\'", cssClass);
                        }
                        if (data.HasChildren)
                        {
                            IHierarchicalEnumerable childEnumerable = data.GetChildren();
                            if (null != childEnumerable)
                            {
                                sb.Append(",\'children\':[");
                                RecursiveDataBindInternal(childEnumerable, sb);
                                sb.Append("]");
                            }
                        }
                        sb.Append("}");
                    }
                }
            }
        }
Esempio n. 2
0
        private PruningTree CreatePruningInformation(IHierarchyData root)
        {
            PruningTree tree = new PruningTree();

            if (root.HasChildren)
            {
                var anyVisible = ShowEmpty;
                foreach (var child in root.GetChildren())
                {
                    var childTree = CreatePruningInformation((IHierarchyData)child);
                    anyVisible = anyVisible || childTree.IsVisible;
                    tree.Children.Add(childTree);
                }
                tree.IsVisible = anyVisible;
            }
            else
            {
                var pc = (PanelContent)root.Item;
                tree.IsVisible = (ShowEmpty || pc.HasResult) && SelectPanelTemplate(root) != null;
                tree.IsVisible = tree.IsVisible &&
                                 (SingletonValues ||
                                  GetPanelTypeEnum(root) != PanelType.Values ||
                                  pc.ResultAsValues().Size > 1);
            }
            return(tree);
        }
Esempio n. 3
0
    // </Snippet3>
    // <Snippet2>
    // Print out the current data node, then iterate through its
    // children and do the same.
    private void PrintFullChildNodeInfo(IHierarchyData node)
    {
        string whitespace = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        string br         = "<BR>";

        Response.Write(node.ToString() + br);
        Response.Write(whitespace + node.Path + br);

        // Check for specific types and perform extended functions.
        if (node.Type == "SiteMapNode")
        {
            // Because SiteMapNode implements the IHierarchyData interface,
            // the IHierarchyData object can be cast directly as a SiteMapNode,
            // rather than accessing the Item property for the object that
            // the Type property identifies.
            SiteMapNode siteNode = node.Item as SiteMapNode;
            Response.Write(whitespace + siteNode.Url + br);
            Response.Write(whitespace + siteNode.Description + br);
        }
        else if (node.Type == "SomeBusinessObject")
        {
            // If the IHierarchyData instance is a wrapper class on a business
            // object of some kind, you can retrieve the business object by using
            // the IHierarchyData.Item property.
            //          SomeBusinessObject busObj = node.Item as SomeBusinessObject;
        }

        if (node.HasChildren)
        {
            IEnumerator children = ((IHierarchicalEnumerable)node.GetChildren()).GetEnumerator();

            while (children.MoveNext())
            {
                // Print out SiteMapNode Titles recursively.
                IHierarchyData hierarchicalNode = node.GetChildren().GetHierarchyData(children.Current);
                PrintFullChildNodeInfo(hierarchicalNode);
            }
        }
    }
Esempio n. 4
0
        void AddItem(C1FlexGrid flex, IHierarchyData item, int level)
        {
            // add this item
            var nd = flex.Rows.AddNode(level);

            nd.Row.UserData = item;
            nd.Data         = ((Category)item).Name;

            // add children
            foreach (IHierarchyData child in item.GetChildren())
            {
                AddItem(flex, child, level + 1);
            }
        }
Esempio n. 5
0
 private void FillBoundChildrenRecursive(IHierarchicalEnumerable hEnumerable, MyTreeNodeCollection nodeCollection)
 {
     if (hEnumerable != null)
     {
         foreach (object obj2 in hEnumerable)
         {
             IHierarchyData hierarchyData = hEnumerable.GetHierarchyData(obj2);
             MyTreeNode     child         = new MyTreeNode(this);
             nodeCollection.Add(child);
             child.Bind(hierarchyData);
             if (((this.MaxDataBindDepth < 0) || (child.Depth != this.MaxDataBindDepth)) && ((hierarchyData != null) && hierarchyData.HasChildren))
             {
                 IHierarchicalEnumerable children = hierarchyData.GetChildren();
                 this.FillBoundChildrenRecursive(children, child.ChildNodes);
             }
         }
     }
 }
Esempio n. 6
0
        private void RecursiveDataBindInternal(IHierarchicalEnumerable enumerable, StringBuilder sb)
        {
            bool first = true;

            if (this.Site != null)
            {
                return;
            }
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);
                if (null != data)
                {
                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
                    if (props.Count > 0)
                    {
                        string title       = ((string)(props["Title"].GetValue(data)));
                        string description = ((string)(props["Description"].GetValue(data)));
                        string url         = ((string)(props["Url"].GetValue(data)));
                        string cssClass    = null;
                        bool   isPublic    = false;
                        if (item is SiteMapNode)
                        {
                            cssClass = ((SiteMapNode)(item))["cssClass"];
                            isPublic = ("true" == ((string)(((SiteMapNode)(item))["public"])));
                        }
                        string    roles    = String.Empty;
                        ArrayList roleList = ((ArrayList)(props["Roles"].GetValue(data)));
                        if (roleList.Count > 0)
                        {
                            roles = String.Join(",", ((string[])(roleList.ToArray(typeof(string)))));
                        }
                        bool resourceAuthorized = true;
                        if (resourceAuthorized)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                sb.Append(",");
                            }
                            sb.AppendFormat("{{title:\"{0}\",url:\"{1}\"", BusinessRules.JavaScriptString(title), BusinessRules.JavaScriptString(url));
                            if (!(String.IsNullOrEmpty(description)))
                            {
                                sb.AppendFormat(",description:\"{0}\"", BusinessRules.JavaScriptString(description));
                            }
                            if (url == Page.Request.RawUrl)
                            {
                                sb.Append(",selected:true");
                            }
                            if (!(String.IsNullOrEmpty(cssClass)))
                            {
                                sb.AppendFormat(",cssClass:\"{0}\"", cssClass);
                            }
                            if (data.HasChildren)
                            {
                                IHierarchicalEnumerable childrenEnumerable = data.GetChildren();
                                if (null != childrenEnumerable)
                                {
                                    sb.Append(",\"children\":[");
                                    RecursiveDataBindInternal(childrenEnumerable, sb);
                                    sb.Append("]");
                                }
                            }
                            sb.Append("}");
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 private void BuildMainMenu(IHierarchicalEnumerable enumerable, StringBuilder sb, int depth)
 {
     foreach (object item in enumerable)
     {
         IHierarchyData data = enumerable.GetHierarchyData(item);
         if (data != null)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
             if (props.Count > 0)
             {
                 string    title       = ((string)(props["Title"].GetValue(data)));
                 string    description = ((string)(props["Description"].GetValue(data)));
                 string    url         = ((string)(props["Url"].GetValue(data)));
                 string    cssClass    = null;
                 string    roles       = null;
                 ArrayList roleList    = ((ArrayList)(props["Roles"].GetValue(data)));
                 if (roleList.Count > 0)
                 {
                     roles = String.Join(",", ((string[])(roleList.ToArray(typeof(string)))));
                 }
                 if (item is SiteMapNode)
                 {
                     cssClass = ((SiteMapNode)(item))["cssClass"];
                     if ("true" == ((SiteMapNode)(item))["public"])
                     {
                         roles = "?";
                     }
                 }
                 sb.AppendFormat("{0} {1}", new String('+', depth), title);
                 sb.AppendLine();
                 if (!(String.IsNullOrEmpty(url)))
                 {
                     sb.AppendLine(url);
                 }
                 else
                 {
                     sb.AppendLine("about:blank");
                 }
                 if (!(String.IsNullOrEmpty(description)))
                 {
                     sb.AppendFormat("description: {0}", description);
                     sb.AppendLine();
                 }
                 if (!(String.IsNullOrEmpty(roles)))
                 {
                     sb.AppendFormat("roles: {0}", roles);
                     sb.AppendLine();
                 }
                 if (!(String.IsNullOrEmpty(cssClass)))
                 {
                     sb.AppendFormat("css-class: {0}", cssClass);
                     sb.AppendLine();
                 }
                 sb.AppendLine();
                 if (data.HasChildren)
                 {
                     IHierarchicalEnumerable childrenEnumerable = data.GetChildren();
                     if (childrenEnumerable != null)
                     {
                         BuildMainMenu(childrenEnumerable, sb, (depth + 1));
                     }
                 }
             }
         }
     }
 }
Esempio n. 8
0
// <snippet5>
        private void RecurseDataBindInternal(TreeNode node,
                                             IHierarchicalEnumerable enumerable, int depth)
        {
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);

                if (null != data)
                {
                    // Create an object that represents the bound data
                    // to the control.
                    TreeNode     newNode = new TreeNode();
                    RootViewNode rvnode  = new RootViewNode();

                    rvnode.Node  = newNode;
                    rvnode.Depth = depth;

                    // The dataItem is not just a string, but potentially
                    // an XML node or some other container.
                    // If DataTextField is set, use it to determine which
                    // field to render. Otherwise, use the first field.
                    if (DataTextField.Length > 0)
                    {
                        newNode.Text = DataBinder.GetPropertyValue
                                           (data, DataTextField, null);
                    }
                    else
                    {
                        PropertyDescriptorCollection props =
                            TypeDescriptor.GetProperties(data);

                        // Set the "default" value of the node.
                        newNode.Text = String.Empty;

                        // Set the true data-bound value of the TextBox,
                        // if possible.
                        if (props.Count >= 1)
                        {
                            if (null != props[0].GetValue(data))
                            {
                                newNode.Text =
                                    props[0].GetValue(data).ToString();
                            }
                        }
                    }

                    Nodes.Add(rvnode);

                    if (data.HasChildren)
                    {
                        IHierarchicalEnumerable newEnumerable =
                            data.GetChildren();
                        if (newEnumerable != null)
                        {
                            RecurseDataBindInternal(newNode,
                                                    newEnumerable, depth + 1);
                        }
                    }

                    if (_maxDepth < depth)
                    {
                        _maxDepth = depth;
                    }
                }
            }
        }