public bool TryGetSearchParameter(string resourceType, string code, out SearchParameterInfo searchParameter)
        {
            searchParameter = null;

            return(TypeLookup.TryGetValue(resourceType, out ConcurrentDictionary <string, SearchParameterInfo> searchParameters) &&
                   searchParameters.TryGetValue(code, out searchParameter));
        }
        /// <summary>
        /// Resolves a type
        /// </summary>
        /// <param name="type">The type to resolve</param>
        /// <returns>The TypeScript type definition</returns>
        protected virtual TsType OnResolve(ITypeSymbol type)
        {
            if (TypeLookup.TryGetValue(type, out var tsType))
            {
                return(tsType);
            }

            if (IsGuid(type))
            {
                return(TsPrimitive.String);
            }

            else if (TypeFilter != null && !TypeFilter(type))             // should this assembly be considered?
            {
                tsType = TsPrimitive.Any;
            }
            else if (type is INamedTypeSymbol namedType && namedType.IsGenericType)
            {
                if ($"{namedType.ContainingNamespace}.{namedType.MetadataName}" == typeof(Task <>).FullName)
                {
                    //Ignore the type "Task" and use the type argument instead.
                    tsType = Resolve(namedType.TypeArguments[0]);
                }
                else
                {
                    var tsGenericType = new TsGenericType(new TsName(type.Name));
                    foreach (var argument in namedType.TypeArguments)
                    {
                        var tsArgType = Resolve(argument);
                        tsGenericType.TypeArguments.Add(tsArgType);
                    }
                    tsType = tsGenericType;
                }
            }
    /// <summary>
    ///
    /// Tries to get the card list for a given dictionary key. Generic so that the key can be suited for any of the constructed dictionaries
    ///
    /// </summary>
    public List <CardData> GetDictionaryList <T>(T key, CardFilter listFilter = null)
    {
        var dictionaryList = new List <CardData>();
        var type           = typeof(T);

        switch (type)
        {
        case Type _ when type == typeof(Tags):
            TagLookup.TryGetValue((Tags)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(Synergies):
            SynergyLookup.TryGetValue((Synergies)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(Classes.ClassList):
            ClassLookup.TryGetValue((Classes.ClassList)(object) key, out dictionaryList);
            break;

        case Type _ when type == typeof(ClassResources):
            ClassPlayableLookup.TryGetValue((ClassResources)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(CardResources):
            ResourceLookup.TryGetValue((CardResources)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(Sets):
            SetLookup.TryGetValue((Sets)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(Rarity):
            RarityLookup.TryGetValue((Rarity)(object)key, out dictionaryList);
            break;

        case Type _ when type == typeof(CardTypes):
            TypeLookup.TryGetValue((CardTypes)(object)key, out dictionaryList);
            break;

        default:
            throw new Exception("Not a valid Dictionary Type");
        }

        if (dictionaryList != null)
        {
            if (listFilter != null)
            {
                return(FilterCardList(dictionaryList.OrderCardList(), listFilter));
            }
            else
            {
                return(dictionaryList.OrderCardList());
            }
        }
        else
        {
            return(new List <CardData>());
        }
    }
        public IEnumerable <SearchParameterInfo> GetSearchParameters(string resourceType)
        {
            if (TypeLookup.TryGetValue(resourceType, out ConcurrentDictionary <string, SearchParameterInfo> value))
            {
                return(value.Values);
            }

            throw new ResourceNotSupportedException(resourceType);
        }
        public SearchParameterInfo GetSearchParameter(string resourceType, string code)
        {
            if (TypeLookup.TryGetValue(resourceType, out ConcurrentDictionary <string, SearchParameterInfo> lookup) &&
                lookup.TryGetValue(code, out SearchParameterInfo searchParameter))
            {
                return(searchParameter);
            }

            throw new SearchParameterNotSupportedException(resourceType, code);
        }
Exemple #6
0
        public static bool TryGetType(StringId id, out DataType type)
        {
            if (m_attrTypes.TryGetValue(id, out type) || m_userTypes.TryGetValue(id, out type))
            {
                return(true);
            }

            type = DataType.BinHex;
            return(false);
        }
        protected TsType Resolve(ITypeSymbol type)
        {
            // see if we have already processed the type
            if (!TypeLookup.TryGetValue(type, out var tsType))
            {
                tsType = OnResolve(type);
            }

            if (tsType == null)
            {
                return(null);
            }

            AddType(tsType, type);
            return(tsType);
        }
Exemple #8
0
        public static ModelType GetForType(Type objectType)
        {
            if (TypeLookup.TryGetValue(objectType, out var modelType))
            {
                return(modelType);
            }

            var possible = from type in ModelTypes
                           let score = type.GetRelation(objectType)
                                       where score.HasValue
                                       orderby score ascending
                                       select type;

            modelType = possible.FirstOrDefault();

            TypeLookup.Add(objectType, modelType);

            return(modelType);
        }