예제 #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();
 }