Esempio n. 1
0
            /// <summary>
            /// Constructs a <see cref="ConditionType.NotHas"/> condition.
            /// </summary>
            /// <param name="labelKey">The target label key</param>
            /// <param name="options">The selector options.</param>
            /// <returns>The <see cref="LabelCondition"/>.</returns>
            public static LabelCondition NotHas(string labelKey, LabelSelectorOptions options)
            {
                ValidateLabelKey(labelKey, options);

                return(new LabelCondition()
                {
                    type = ConditionType.NotHas,
                    labelKey = labelKey
                });
            }
Esempio n. 2
0
            /// <summary>
            /// Validates a label value.
            /// </summary>
            /// <param name="labelValue">The label value.</param>
            /// <param name="options">The selector options.</param>
            /// <exception cref="FormatException">Thrown if the key is not valid.</exception>
            public static void ValidateLabelValue(string labelValue, LabelSelectorOptions options)
            {
                Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(labelValue), nameof(labelValue));

                if ((options & LabelSelectorOptions.UnConstraintedLabels) != 0)
                {
                    return;
                }

                LabelSelector.ValidateLabelValue(labelValue);
            }
Esempio n. 3
0
            /// <summary>
            /// Constructs a <see cref="ConditionType.NotEqual"/> condition.
            /// </summary>
            /// <param name="labelKey">The target label key.</param>
            /// <param name="value">The value.</param>
            /// <param name="options">The selector options.</param>
            /// <returns>The <see cref="LabelCondition"/>.</returns>
            public static LabelCondition NotEqual(string labelKey, string value, LabelSelectorOptions options)
            {
                ValidateLabelKey(labelKey, options);
                ValidateLabelValue(value, options);

                return(new LabelCondition()
                {
                    type = ConditionType.NotEqual,
                    labelKey = labelKey,
                    labelValue = value
                });
            }
Esempio n. 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="items">The set of items to be queries.  <c>null</c> will treated as an empty set.</param>
 /// <param name="options">Optionally customize selector case sensitivity and other behaviors.</param>
 public LabelSelector(IEnumerable <TItem> items, LabelSelectorOptions options = LabelSelectorOptions.None)
 {
     this.items   = items ?? new List <TItem>();
     this.options = options;
 }
Esempio n. 5
0
            /// <summary>
            /// Constructs a <see cref="ConditionType.NotIn"/> condition.
            /// </summary>
            /// <param name="labelKey">The target label key.</param>
            /// <param name="values">The values.</param>
            /// <param name="options">The selector options.</param>
            /// <returns>The <see cref="LabelCondition"/>.</returns>
            public static LabelCondition NotIn(string labelKey, IEnumerable <string> values, LabelSelectorOptions options)
            {
                ValidateLabelKey(labelKey, options);

                foreach (var value in values)
                {
                    ValidateLabelValue(value, options);
                }

                return(new LabelCondition()
                {
                    type = ConditionType.NotIn,
                    labelKey = labelKey,
                    labelValues = values
                });
            }