Statistics
| Branch: | Revision:

root / trunk / Pithos.OFM / ObjectRecord.cs @ ac8b664d

History | View | Annotate | Download (1.4 kB)

1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using Pithos.Interfaces;
5

    
6
namespace Pithos.OFM
7
{
8
    public class ObjectRecord : IEnumerable<ObjectRecord>
9
    {
10
        public string DisplayName { get; set; }
11

    
12
        public Uri Uri { get; set; }
13

    
14
        private ObjectInfo _objectInfo;
15
        public ObjectInfo ObjectInfo
16
        {
17
            get { return _objectInfo; }
18
            set
19
            {
20
                _objectInfo = value;
21
                Uri = value.Uri;
22
            }
23
        }
24

    
25

    
26
        private List<ObjectRecord> _directories = new List<ObjectRecord>();
27
        public List<ObjectRecord> Directories
28
        {
29
            get { return _directories; }
30
            set
31
            {
32
                _directories = value;
33
                foreach (var dir in value)
34
                {
35
                    dir.Parent = this;
36
                }
37
            }
38
        }
39

    
40
        protected ObjectRecord Parent { get; set; }
41

    
42
        public IEnumerator<ObjectRecord> GetEnumerator()
43
        {
44
            yield return this;
45
            foreach (var children in Directories)
46
                foreach (var info in children)
47
                {
48
                    yield return info;
49
                }
50
        }
51

    
52
        IEnumerator IEnumerable.GetEnumerator()
53
        {
54
            return GetEnumerator();
55
        }
56

    
57
    }
58
}