Ejemplo n.º 1
0
        /// <summary>
        /// Filter a response with a wildcard expression contained in a <see cref="NameOrObject{T}"/> value.
        /// </summary>
        /// <typeparam name="T">The type of <see cref="PrtgObject"/> possibly contained in <paramref name="obj"/>.</typeparam>
        /// <param name="obj">The object that possibly contains a wildcard expression.</param>
        /// <param name="getProperty">A function that retrieves the property to filter by from each record.</param>
        /// <param name="records">The records to filter.</param>
        /// <returns>If <paramref name="obj"/> contains a wildcard expression, the filtered collection. Otherwise, the original collection.</returns>
        protected IEnumerable <TObject> FilterResponseRecordsByNameOrObjectName <T>(NameOrObject <T> obj, Func <TObject, string> getProperty, IEnumerable <TObject> records) where T : PrtgObject
        {
            if (obj != null && !obj.IsObject)
            {
                return(FilterResponseRecords(records, obj.Name, getProperty));
            }

            return(records);
        }
Ejemplo n.º 2
0
        internal IEnumerable <TObject> GetAdditionalGroupRecords(NameOrObject <Group> group, Func <Group, int> objsOfTypeInGroup, TParam parameters)
        {
            if (group != null && group.IsObject)
            {
                return(GetAdditionalGroupRecords(group.Object, objsOfTypeInGroup, parameters));
            }

            return(new List <TObject>());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add a filter for the value contained in a <see cref="NameOrObject{T}"/> object.
 /// </summary>
 /// <typeparam name="T">The type of <see cref="PrtgObject"/> possibly contained in <paramref name="obj"/>.</typeparam>
 /// <param name="objectProperty">The property to filter on if <paramref name="obj"/> contains an object.</param>
 /// <param name="obj">The object that either contains a <see cref="PrtgObject"/> or a wildcard expression specifying the object name to filter by.</param>
 /// <param name="getValue">A function that retrieves the property to filter by from the <see cref="PrtgObject"/> when <paramref name="obj"/> contains an object.</param>
 /// <param name="nameProperty">The property to filter by when <paramref name="obj"/> does not contain an object. If this value is null, <paramref name="objectProperty"/> will be used as the filter property.</param>
 protected void AddNameOrObjectFilter <T>(Property objectProperty, NameOrObject <T> obj, Func <T, object> getValue, Property?nameProperty = null) where T : PrtgObject
 {
     if (obj.IsObject)
     {
         AddPipelineFilter(objectProperty, getValue(obj.Object));
     }
     else
     {
         AddWildcardFilter(nameProperty ?? objectProperty, obj.Name);
     }
 }