Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sébastien Richer 194 posts 430 karma points
    Jun 04, 2013 @ 20:49
    Sébastien Richer
    1

    Multi node tree picker deserialize

    Hello,

    I use this with my uComponents url picker:

    var destination = uComponents.DataTypes.UrlPicker.Dto.UrlPickerState.Deserialize(Model.Content.GetPropertyValue("destination").ToString());
    if (!string.IsNullOrWhiteSpace(destination.Url))
    {
    // Stuff
    }

    Works like a charm! I'm looking for the same thing with my multi node tree picker here. Is there a fun way to do this?

    Here is the piece of code I'm trying to make cooler (maybe I'm just not taking the proper approach...):

    foreach (var subExpertise in Model.Content.Children)
    {
        projects.AddRange(lang.Descendants("Projet").Where(x => ((MNTP)x.AsDynamic().Expertise).nodeId == subExpertise.Id));
    }

    Any help will be appreciated!

    Thanks!

  • Amir 75 posts 224 karma points
    May 07, 2014 @ 17:39
    Amir
    0

    This post is a bit old, but I think I can share my experience and workaroud for situations like this.

    I tried to find a deserializer as well for MultiNodeTreePicker but couldnt find any, so I created my own which handles the variables in XML format as below:

    public static List<Node> GetMultiNodePickerContentItems(string xmlFormatString)
            {
                List<Node> retVal = new List<Node>();

                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(xmlFormatString);

                if (xdoc.FirstChild.Name == "MultiNodePicker")
                {
                    foreach (XmlNode xnod in xdoc.FirstChild.ChildNodes)
                    {
                        if (xnod.Name == "nodeId")
                        {
                            int nodeId = -1;
                            if (Int32.TryParse(xnod.InnerText, out nodeId)) retVal.Add(new Node(nodeId));
                        }
                    }
                }
                return retVal;
            }
     

    And Calling it is like:

    foreach (Node linkItemNode in Helper.GetMultiNodePickerContentItems(thisNode.GetProperty("links").Value))
                            {
                                ................
                            }



     

Please Sign in or register to post replies

Write your reply to:

Draft