Esempio n. 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 /// <param name="parent">Parent</param>
 public LogItemWrapper(LogDirectoryWrapper parent, ILogData item)
 {
     this.item   = item;
     this.parent = parent;
     parent.items.Add(this);
     StaticExtensionEventLogDatabase.items[item.Id] = this;
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 /// <param name="parent">Parent</param>
 public LogIntervalWrapper(LogDirectoryWrapper parent, ILogInterval interval, ILogData data) :
     this(interval)
 {
     this.parent = parent;
     parent.items.Add(this);
     this.data = data;
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a tree
        /// </summary>
        /// <param name="data">Database interface</param>
        /// <returns>roots of trees</returns>
        static ILogDirectory[] CreateTree(this IDatabaseInterface data)
        {
            Dictionary <object, IParentSet> dictionary  = new Dictionary <object, IParentSet>();
            IEnumerable <object>            list        = data.Elements;
            List <ILogDirectory>            directories = new List <ILogDirectory>();

            foreach (object o in list)
            {
                ILogItem   item = data[o];
                IParentSet ps   = null;
                if (item is ILogInterval)
                {
                    ps = new LogIntervalWrapper(item as ILogInterval);
                }
                else if (item is ILogData)
                {
                    ps = new LogItemWrapper(item as ILogData);
                }
                else
                {
                    ps = new LogDirectoryWrapper(item);
                }
                dictionary[o] = ps;
            }
            foreach (IParentSet ps in dictionary.Values)
            {
                ILogItem it = (ps as ILogItem);
                object   o  = it.ParentId;
                if (!o.Equals(it.Id))
                {
                    if (dictionary.ContainsKey(o))
                    {
                        ps.Parent = dictionary[o] as ILogItem;
                    }
                }
                if (it is ILogInterval)
                {
                    ILogInterval interval = it as ILogInterval;
                    ILogData     d        = dictionary[interval.DataId] as ILogData;
                    (interval as LogIntervalWrapper).DataSet = d;
                }
            }
            List <ILogDirectory> l = new List <ILogDirectory>();

            foreach (IParentSet ps in dictionary.Values)
            {
                if (ps is ILogDirectory)
                {
                    ILogDirectory item = (ps as ILogDirectory);
                    if (item.Parent == null)
                    {
                        l.Add(item);
                    }
                }
            }
            return(l.ToArray());
        }