Example #1
0
        private int ItemtoNode(object d, IFreeDocument dict)
        {
            var doc = dict as FreeDocument;

            if (doc == null)
            {
                if (d is JsonObject)
                {
                    dict.DictDeserialize(d as JsonObject);
                }
            }
            else
            {
                if (d is JsonArray)
                {
                    foreach (var item in d as JsonArray)
                    {
                        var item2 = new FreeDocument();
                        ItemtoNode(item, item2);
                        if (doc.Children == null)
                        {
                            doc.Children = new List <FreeDocument>();
                        }
                        doc.Children.Add(item2);
                    }
                    return(1);
                }
                else if (d is JsonObject)
                {
                    var jb = d as JsonObject;
                    foreach (var b in jb)
                    {
                        var dict2 = new FreeDocument();
                        var res   = ItemtoNode(b.Value, dict2);
                        if (res == 0)
                        {
                            doc.Add(b.Name, b.Value);
                        }
                        else if (res == 1)
                        {
                            doc.Add(b.Name, dict2);
                        }
                    }

                    return(2);
                }
            }
            return(0);
        }
Example #2
0
        public void SetObjects(IFreeDocument item, object[] value, string[] titles = null)
        {
            int index  = 0;
            var values = new Dictionary <string, object>();

            if (item is IFreeDocument)
            {
                if (titles == null)
                {
                    foreach (object o in value)
                    {
                        values.Add(string.Format("Row{0}", index), value[index]);
                        index++;
                    }
                }
                else
                {
                    foreach (object o in value)
                    {
                        values.Add(titles[index], value[index]);
                        index++;
                    }
                }
            }
            else
            {
                foreach (string o in item.DictSerialize().Keys.OrderBy(d => d))
                {
                    values.Add(o, value[index]);
                    index++;
                }
            }

            item.DictDeserialize(values);
            ;
        }
Example #3
0
        private int ItemtoNode(object d, IFreeDocument dict)
        {
            var doc = dict as FreeDocument;
            if (doc == null)
            {
                if (d is JsonObject)
                    dict.DictDeserialize(d as JsonObject);
            }
            else
            {
                if (d is JsonArray)
                {
                    foreach (var item in d as JsonArray)
                    {
                        var item2 = new FreeDocument();
                        ItemtoNode(item, item2);
                        if (doc.Children == null)
                        {
                            doc.Children = new List<FreeDocument>();
                        }
                        doc.Children.Add(item2);

                    }
                    return 1;
                }
                else if (d is JsonObject)
                {
                    var jb = d as JsonObject;
                    foreach (var b in jb)
                    {
                        var dict2 = new FreeDocument();
                        var res = ItemtoNode(b.Value, dict2);
                        if (res == 0)
                        {
                            doc.Add(b.Name, b.Value);
                        }
                        else if (res == 1)
                        {
                            doc.Add(b.Name, dict2);
                        }
                    }

                    return 2;

                }
            }
            return 0;
        }