Esempio n. 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LogSourceNode"/>.
		/// </summary>
		/// <param name="key">The unique key.</param>
		/// <param name="name">The display name.</param>
		/// <param name="parentNode">The parent node.</param>
		public LogSourceNode(Guid key, string name, LogSourceNode parentNode)
		{
			//if (key.IsEmpty())
			//	throw new ArgumentNullException("key");

			if (name.IsEmpty())
				throw new ArgumentNullException(nameof(name));

			Key = key;
			Name = name;
			ParentNode = parentNode;

			KeyStr = Key.ToString();
			ChildNodes = new ThreadSafeObservableCollection<LogSourceNode>(new ObservableCollectionEx<LogSourceNode>());
		}
Esempio n. 2
0
        private NodeInfo EnsureBuildNodes(ILogSource source)
        {
            var info = _logInfo.TryGetValue(source.Id);

            if (info != null)
            {
                return(info);
            }

            // если новый источник данных
            var newSources = new Stack <ILogSource>();

            newSources.Push(source);

            var root = source.Parent;

            // ищем корневую ноду, которая уже была ранее добавлена
            while (root != null && !_logInfo.ContainsKey(root.Id))
            {
                newSources.Push(root);
                root = root.Parent;
            }

            LogSourceNode parentNode;

            // если корневой ноды нет, то создаем ее, основываясь на корневом источнике
            if (root == null)
            {
                parentNode = (newSources.Peek() is Strategy)
                                        ? SourcesTree.StrategyRootNode
                                        : SourcesTree.CoreRootNode;
            }
            else
            {
                parentNode = _logInfo[root.Id].Item2;
            }

            // добавляем поочередно ноды для новых источников
            foreach (var newSource in newSources)
            {
                var sourceNode = new LogSourceNode(newSource.Id, newSource.Name, parentNode);
                parentNode.ChildNodes.Add(sourceNode);
                parentNode = sourceNode;
                _logInfo.Add(newSource.Id, new NodeInfo(sourceNode));
            }

            return(_logInfo[source.Id]);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogSourceNode"/>.
        /// </summary>
        /// <param name="key">The unique key.</param>
        /// <param name="name">The display name.</param>
        /// <param name="parentNode">The parent node.</param>
        public LogSourceNode(Guid key, string name, LogSourceNode parentNode)
        {
            //if (key.IsEmpty())
            //	throw new ArgumentNullException("key");

            if (name.IsEmpty())
            {
                throw new ArgumentNullException(nameof(name));
            }

            Key        = key;
            Name       = name;
            ParentNode = parentNode;

            KeyStr     = Key.ToString();
            ChildNodes = new ThreadSafeObservableCollection <LogSourceNode>(new ObservableCollectionEx <LogSourceNode>());
        }