Esempio n. 1
0
        public static TypescriptGenericTypeArguments GetGenericTypeParametersAsArguments(Type type)
        {
            var parameters = GetGenericTypeParametersFor(type);
            var arguments  = new TypescriptGenericTypeArguments();

            parameters.ForEach(x => arguments.Add(x));
            return(arguments);
        }
Esempio n. 2
0
        public static TypescriptGenericTypeArguments GetGenericTypeParametersAsArguments(this Type type)
        {
            // TODO add argument validation
            var parameters = GetGenericTypeParametersFor(type);
            var arguments  = new TypescriptGenericTypeArguments();

            parameters.ForEach(x => arguments.Add(x));
            return(arguments);
        }
Esempio n. 3
0
        public static TypescriptGenericTypeArguments GetGenericTypeArgumentsFor(ITypescriptTypeCreator typeCreator, Type baseType, TypescriptModel model)
        {
            var result = new TypescriptGenericTypeArguments();

            foreach (var genericTypeArgument in baseType.GetGenericArguments())
            {
                var tsType = typeCreator.GetTypeFor(genericTypeArgument, model);

                tsType.Match(
                    primitive => result.Add(primitive),
                    tsClass => result.Add(tsClass),
                    tsInterface => result.Add(tsInterface),
                    tsEnumerable => { throw new Exception("enum cannot be a generic type parameter"); },
                    genericTypeParameter => result.Add(genericTypeParameter));
            }
            return(result);
        }