Beispiel #1
0
        /// <summary>
        /// Converts a lowercase component name from an URL into the C# Type name.
        /// Examples:
        ///   table --> MudTable<T>
        ///   button  MudButton
        ///   appbar  AppBar
        /// </summary>
        public static Type GetTypeFromComponentLink(string component)
        {
            if (string.IsNullOrEmpty(component))
            {
                return(null);
            }
            if (InverseSpecialCase.TryGetValue(component, out var type))
            {
                return(type);
            }
            var assembly = typeof(MudComponentBase).Assembly;
            var lookup   = new Dictionary <string, Type>();

            foreach (var x in assembly.GetTypes())
            {
                lookup[x.Name.ToLowerInvariant()] = x;
            }
            var type_lower = $"mud{component}".ToLowerInvariant();

            if (!lookup.TryGetValue(type_lower, out type))
            {
                return(null);
            }
            return(type);
        }
Beispiel #2
0
        /// <summary>
        /// Converts "table" into typeof(MudTable<T>) or "button" into typeof(MudButton)
        /// </summary>
        public static Type GetTypeFromComponentLink(string component)
        {
            if (InverseSpecialCase.TryGetValue(component, out var type))
            {
                return(type);
            }
            var type_name = $"MudBlazor.Mud{component.ToPascalCase()}";
            var assembly  = typeof(MudComponentBase).Assembly;

            type = assembly.GetType(type_name);
            return(type);
        }