Ejemplo n.º 1
0
        public static AccountType ParseFromHumanName(this string name)
        {
            var accountType = NameToTypes.GetOrDefault(name);

            if (accountType == null)
            {
                throw new FormatException("Unknown account type human name");
            }
            return(accountType.Value);
        }
        private ILType GetTypeInternal(ITypeSymbol symbol)
        {
            var fullname = symbol.FullName;
            IListView <ILType> list;

            if (!NameToTypes.TryGetValues(fullname, out list))
            {
                return(CreateTypeInternal(symbol));
            }

            int    currentScore = int.MinValue;
            ILType currentType  = null;

            foreach (var type in list)
            {
                int score;
                if (Score.GetTypeWeakMatchScore(type, symbol, out score))
                {
                    if (score > currentScore)
                    {
                        currentScore = score;
                        currentType  = type;
                    }
                }
            }
            if (currentType == null)
            {
                return(CreateTypeInternal(symbol));
            }
            if (currentScore >= 0)
            {
                return(currentType);
            }
            var typeInternal = CreateTypeInternal(symbol);

            return(typeInternal ?? currentType);
        }
Ejemplo n.º 3
0
 public static bool ExistsAccountType(this string humanName)
 {
     return(NameToTypes.GetOrDefault(humanName) != null);
 }