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

            doc.AddRange(children);
            return(doc);
        }
Exemple #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)));
        }
Exemple #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;
        }
Exemple #4
0
 private static IEnumerable<TreeDoc> FindAncestorsAndSelf(TreeDoc doc)
 {
     while (doc != null)
     {
         yield return doc;
         doc = doc.Parent;
     }
 }
Exemple #5
0
 public void RemoveAt(int index, TreeDoc item)
 {
     mChildren.RemoveAt(index);
     InternalDestroyListIfEmpty();
 }
Exemple #6
0
 public bool IsBefore(TreeDoc other)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 public bool IsAfter(TreeDoc other)
 {
     throw new NotImplementedException();
 }
Exemple #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;
 }
Exemple #9
0
 public static TreeDoc CreateListRange(IEnumerable children)
 {
     TreeDoc doc = new TreeDoc("");
     doc.AddRange(children);
     return doc;
 }
Exemple #10
0
 public static TreeDoc CreateListRange(string name, IEnumerable children)
 {
     TreeDoc doc = new TreeDoc(name);
     doc.AddRange(children);
     return doc;
 }
Exemple #11
0
 public static TreeDoc CreateLeaf(string name, string value)
 {
     TreeDoc doc = new TreeDoc(name);
     doc.Value = value;
     return doc;
 }
Exemple #12
0
 public void RemoveAt(int index, TreeDoc item)
 {
     mChildren.RemoveAt(index);
     InternalDestroyListIfEmpty();
 }