private List <UserStateSearchItem> GetValidUserStatesList(UserStateAttributeValueToken target) { var specifiedTypesNames = target.Context[nameof(TypeArgumentToken)].Value as List <string> ?? new List <string>(); specifiedTypesNames = specifiedTypesNames.Where(x => !string.IsNullOrEmpty(x)).ToList(); var types = _context.GetTypes() .OrderBy(x => x.Value.IsDeleted) .ThenBy(x => x.Value.Sort) .Where(x => IsUserType(x.Value) && (!specifiedTypesNames.Any() || specifiedTypesNames.Contains(x.Value.Id.ToString()))) .ToList(); var specifiedAttributeName = target.Context[nameof(AttributeNameTokenBase)].Value as string; var attributeTypePairs = types .Select(t => new Tuple <INAttribute, INType>(t.Value.Attributes.FirstOrDefault(a => a.Name == specifiedAttributeName), t.Value)) .Where(pair => pair.Item1 != null) .ToList(); var validUserStates = BuildItemsIntersection( sourceElements: attributeTypePairs, intersect: specifiedTypesNames.Count > 1, buildItemsForElement: attributeTypePair => { var stateMachineId = attributeTypePair.Item1.ParsedConfiguration().StateMachineId; if (stateMachineId == null) { return(new Dictionary <string, UserStateSearchItem>()); } var stateMachine = _context.GetStateMachine((Guid)stateMachineId); var presetItems = stateMachine.StateTransitions .Select(state => _context.GetUserState(state.Key)) .Where(state => state != null) .ToDictionary(state => state.Name, state => new UserStateSearchItem(state) { Tooltip = attributeTypePair.Item2.Title }); return(presetItems); }, onItemDuplicated: (presetItem, attributeTypePair) => { presetItem.Tooltip += GetTooltipEntryForType(attributeTypePair.Item2); }); return(validUserStates); }