示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrtgOrphan{TValue}"/> class with a specified tree value and children.
 /// </summary>
 /// <param name="value">The tree value to encapsulate in this orphan.</param>
 /// <param name="children">The children of this orphan.</param>
 /// <param name="type">The type of this orphan.</param>
 internal PrtgOrphan(ITreeValue value, IEnumerable <PrtgOrphan> children, PrtgNodeType type) : base(value, children, type)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
 }
示例#2
0
 internal TreeBuilderLevel(ITreeValue value, PrtgNodeType valueType, Func <ITreeValue, IEnumerable <PrtgOrphan>, PrtgOrphan> getOrphan, TreeBuilder builder)
 {
     Value        = value;
     ValueType    = valueType;
     GetOrphan    = getOrphan;
     this.builder = builder;
 }
        public void OnProcessType(PrtgNodeType type, int index, int total)
        {
            ProgressManager.TotalRecords = total;

            ProgressManager.InitialDescription = $"Retrieving all {type.ToString().ToLower()}s";

            ProgressManager.WriteProgress("PRTG Tree Search", ProgressManager.InitialDescription);
            ProgressManager.UpdateRecordsProcessed(ProgressManager.CurrentRecord, null, true);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrtgOrphan"/> class.
        /// </summary>
        /// <param name="value">The value this orphan encapsulates.</param>
        /// <param name="children">The children of this orphan.</param>
        /// <param name="type">The type of this orphan.</param>
        internal PrtgOrphan(ITreeValue value, IEnumerable <PrtgOrphan> children, PrtgNodeType type) : base(ReduceChildren(children), (int)type)
        {
            Value = value;

            //We only have a cached enumeration of children when we lazily retrieved them from PRTG in a TreeLevelBuilder.
            //As such, skip validating the children.
            if (!(children is CachedEnumerableIterator <PrtgOrphan>))
            {
                ValidateChildren(Children);
            }
        }
示例#5
0
        private Func <int, int, Task> GetFastObjectsAsync <T>(PrtgNodeType type, Task <List <T> > getObjectsAsync, bool skipProgress = false)
        {
            Func <int, int, Task <List <T> > > func = async(i, t) =>
            {
                if (!skipProgress)
                {
                    lock (lockObj)
                    {
                        ProgressManager.OnProcessType(type, i, t);
                    }
                }

                return(await getObjectsAsync.ConfigureAwait(false));
            };

            return(func);
        }
示例#6
0
        internal PrtgOrphan ValidateAndUpdate <T>(IEnumerable <PrtgOrphan> children, PrtgNodeType type, Func <IEnumerable <T>, PrtgOrphan> create)
        {
            if (children != Children)
            {
                var collection = children.AsCollection();

                var invalid = collection.Where(c => !(c is T)).ToArray();

                if (invalid.Length > 0)
                {
                    throw new InvalidOperationException($"Cannot add child of type '{invalid[0].Type}' to '{GetType().Name}': child must be of type '{type}'.");
                }

                return(create(children.Cast <T>()));
            }

            return(this);
        }
        public void OnLevelBegin(ITreeValue value, PrtgNodeType type, int depth)
        {
            var typeDescription = IObjectExtensions.GetTypeDescription(value.GetType());

            var str = typeDescription.ToLower();

            if (value.Id == WellKnownId.Root)
            {
                ProgressManager.InitialDescription = "Processing children of 'Root' Group";
            }
            else
            {
                ProgressManager.InitialDescription = $"Processing children of {str} '{value}'";

                if (value is IPrtgObject)
                {
                    ProgressManager.InitialDescription += $" (ID: {value.Id})";
                }
            }

            var activity = depth == 1 ? "PRTG Tree Search" : $"PRTG {typeDescription} Tree Search";

            ProgressManager.WriteProgress(activity, $"Retrieving children of {str} '{value}'");
        }
 public void OnLevelWidthKnown(ITreeValue parent, PrtgNodeType type, int width)
 {
     ProgressManager.TotalRecords = width;
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrtgOrphanCollection"/> collection class.
 /// </summary>
 /// <param name="children">The children of this collection.</param>
 /// <param name="type">The type of this collection.</param>
 protected PrtgOrphanCollection(IEnumerable <PrtgOrphan> children, PrtgNodeType type = PrtgNodeType.Collection) : base(null, FlattenCollections(children), type)
 {
 }
示例#10
0
 public void OnProcessType(PrtgNodeType type, int index, int total)
 {
     progressCallback?.OnProcessType(type, index, total);
 }
示例#11
0
 public void OnLevelWidthKnown(ITreeValue parent, PrtgNodeType parentType, int width)
 {
     progressCallback?.OnLevelWidthKnown(parent, parentType, width);
 }
示例#12
0
 public void OnLevelBegin(ITreeValue value, PrtgNodeType type)
 {
     progressCallback?.OnLevelBegin(value, type, depthManager.Depth);
 }