internal static string[] GetNamesTyped(this Blackboard blackboard, BlackboardProperty typeMask, params Type[] compatableTypes) { if (blackboard != null && compatableTypes != null && compatableTypes.Length > 0) { var result = new List <string>(); var names = blackboard.GetNames(typeMask); foreach (var n in names) { Type type = null; if (typeMask.IncludesGetter()) { if (blackboard.GetterValues.TryGetValue(n, out var getAccessor)) { type = getAccessor.PropertyType; } } else if (typeMask.IncludesSetter()) { if (blackboard.SetterValues.TryGetValue(n, out var setAccessor)) { type = setAccessor.PropertyType; } } if (type != null) { if (TypeArrayContainsTypeOrBaseType(compatableTypes, type)) { result.Add(n); } } } return(result.ToArray()); } return(s_emptyNames); }
internal static string[] GetNames(this Blackboard blackboard, BlackboardProperty typeMask) { if (blackboard == null || blackboard.GetterValues == null || blackboard.SetterValues == null) { return(s_emptyNames); } string[] namesResult = new string[0]; if (typeMask.IncludesGetter()) { var names = blackboard.GetterValues.Keys.Where(key => !string.IsNullOrEmpty(key)); namesResult = namesResult.Concat(names).ToArray(); } if (typeMask.IncludesSetter()) { var names = blackboard.SetterValues.Keys.Where(key => !string.IsNullOrEmpty(key) && !namesResult.Contains(key)); namesResult = namesResult.Concat(names).ToArray(); } return(namesResult); }