示例#1
0
        public static TreeDoc CreateListRange(string name, IEnumerable children)
        {
            TreeDoc doc = new TreeDoc(name);

            doc.AddRange(children);
            return(doc);
        }
示例#2
0
        public static TreeDoc ObjectToTreeDoc(object item)
        {
            if (item == null)
            {
                return(TreeDoc.CreateNull());
            }
            if (item is TreeDoc)
            {
                return((TreeDoc)item);
            }
            if (item is String)
            {
                return(TreeDoc.CreateLeaf((String)item));
            }
            Func <TreeDoc> converter = (Func <TreeDoc>)Delegate.CreateDelegate(typeof(Func <TreeDoc>), item, "ToTreeDoc", false, false);

            if (converter != null)
            {
                return(converter());
            }
            return(TreeDoc.CreateLeaf(ObjectToString(item)));
        }
示例#3
0
        public void Insert(int index, TreeDoc item)
        {
            int count;

            if (mChildren != null)
            {
                count = mChildren.Count;
            }
            else
            {
                count = 0;
            }
            if ((uint)index > count)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (item.Parent != null)
            {
                throw new InvalidOperationException("item has a parent already");
            }
            InternalRequireList();
            mChildren.Insert(index, item);
            item.Parent = this;
        }
示例#4
0
 private static IEnumerable<TreeDoc> FindAncestorsAndSelf(TreeDoc doc)
 {
     while (doc != null)
     {
         yield return doc;
         doc = doc.Parent;
     }
 }
示例#5
0
 public void RemoveAt(int index, TreeDoc item)
 {
     mChildren.RemoveAt(index);
     InternalDestroyListIfEmpty();
 }
示例#6
0
 public bool IsBefore(TreeDoc other)
 {
     throw new NotImplementedException();
 }
示例#7
0
 public bool IsAfter(TreeDoc other)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public void Insert(int index, TreeDoc item)
 {
     int count;
     if (mChildren != null)
         count = mChildren.Count;
     else
         count = 0;
     if ((uint)index > count)
         throw new ArgumentOutOfRangeException();
     if (item.Parent != null)
         throw new InvalidOperationException("item has a parent already");
     InternalRequireList();
     mChildren.Insert(index, item);
     item.Parent = this;
 }
示例#9
0
 public static TreeDoc CreateListRange(IEnumerable children)
 {
     TreeDoc doc = new TreeDoc("");
     doc.AddRange(children);
     return doc;
 }
示例#10
0
 public static TreeDoc CreateListRange(string name, IEnumerable children)
 {
     TreeDoc doc = new TreeDoc(name);
     doc.AddRange(children);
     return doc;
 }
示例#11
0
 public static TreeDoc CreateLeaf(string name, string value)
 {
     TreeDoc doc = new TreeDoc(name);
     doc.Value = value;
     return doc;
 }
示例#12
0
 public void RemoveAt(int index, TreeDoc item)
 {
     mChildren.RemoveAt(index);
     InternalDestroyListIfEmpty();
 }