/// <summary> /// Compares with another <see cref="MultiStringValue"/> and returns a value to indicate /// whether all items in this value are present in the other. /// </summary> /// <param name="other"> /// The other <see cref="MultiStringValue"/> to compare with. /// </param> /// <param name="comparison"> /// Specifies how to compare string values. /// </param> /// <returns> /// <c>true</c> both values contains same number of <see cref="Items"/> /// and all <see cref="Items"/> in this value are present in <paramref name="other"/>. /// </returns> public virtual bool EqualsSemantically(MultiStringValue other, StringComparison comparison = StringComparison.InvariantCulture) { var length = Items.Length; if (other is null || length != other.Items.Length) { return(false); } for (var i = 0; i < length; i++) { var test = Items[i]; var match = false; for (var j = 0; j < length && !match; j++) { match = test.Equals(other.Items[j]); } if (!match) { return(false); } } return(true); }
public static MultiStringValue Join(this MultiStringValue self, string[] items, bool trimDuplicates) { var list = new List <string>(self.Items); list.AddRange(items); return(trimDuplicates ? MultiStringValue.WithoutDuplicates(list.ToArray()) : new MultiStringValue(list.ToArray())); }
public static MultiStringValue Join(this MultiStringValue self, MultiStringValue other, bool trimDuplicates) { var list = new List <string>(self.Items); list.AddRange(other.Items); var items = list.ToArray(); return(trimDuplicates ? MultiStringValue.WithoutDuplicates(items) : new MultiStringValue(items)); }
public static bool Any(this MultiStringValue self, MultiStringValue other) { return(!other.IsEmpty() && other.Items.Any(item => self.Items.Any(i => i == item))); }
public static bool IsEmpty(this MultiStringValue self) => !self?.Items.Any() ?? true;
/// <summary> /// Determines whether the specified value is equal to the current value. /// </summary> /// <param name="other"> /// A <see cref="MultiStringValue"/> value to compare to this value. /// </param> /// <returns> /// <c>true</c> if <paramref name="other"/> is equal to the current value; otherwise <c>false</c>. /// </returns> public virtual bool Equals(MultiStringValue other) { return(!(other is null) && string.Equals(StringValue, other.StringValue)); }