Esempio n. 1
0
        /// <summary>
        /// Matches the datatype of the symbol and the candidates
        /// </summary>
        /// <param name="symbol">The symbol.</param>
        /// <returns>True if there are candidates left</returns>
        private IEnumerable <IBaseConfigModel> MatchDataType(ISymbol symbol, IEnumerable <IBaseConfigModel> candidates)
        {
            var matches = new List <IBaseConfigModel>();

            foreach (Member member in candidates)
            {
                var typeMatch = true;

                if (member.DataType?.Custom == true && member.DataType.TypeName == ((Component)member.Parent).Name)
                {
                    // returns the parentname, can be checked
                    typeMatch = SymbolMatcher.MatchDataType(symbol, symbol.ContainingSymbol.Name);
                }
                else if (member.DataType?.Custom == false)
                {
                    typeMatch = SymbolMatcher.MatchDataType(symbol, member.DataType.Type.Name);
                }
                else
                {
                    // Not able to determine the correct type at this time
                }

                if (member.DataType != null)
                {
                    typeMatch &= SymbolMatcher.MatchCollection(symbol, member.DataType.Collection);
                }

                if (typeMatch)
                {
                    matches.Add(member);
                }
            }

            return(matches);
        }