1234567891011121314151617181920212223242526272829 |
- namespace EventBus
- {
- public static class PropertiesToolkit
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="properties"></param>
- /// <returns></returns>
- public static bool FilterRule(this Properties source, Properties properties)
- {
- if (source == null) return true;
- if (source.Count == 0) return true;
- if (properties == null) properties = Properties.Default;
- if (source.Names.Intersect(properties.Names).Count() != source.Count) return false;
- foreach (var name in source.Names)
- {
- if (!source.TryGetValue(name, out string val)) return false;
- else
- {
- string valstr = properties[name];
- if (string.IsNullOrEmpty(valstr)) return false;
- return val.Contains(valstr);
- }
- }
- return true;
- }
- }
- }
|