Sarcasm.Reflection.MetaFormatter.IsFormatterType C# (CSharp) Méthode

IsFormatterType() public static méthode

public static IsFormatterType ( Type type ) : bool
type System.Type
Résultat bool
        public static bool IsFormatterType(Type type)
        {
            return type.IsSubclassOf(typeof(Formatter)) && type.GetCustomAttribute<FormatterAttribute>() != null;
        }

Usage Example

Exemple #1
0
        public void RegisterFormatters(Assembly assembly)
        {
            var newMetaFormatters = assembly
                                    .GetTypes()
                                    .Where(type => MetaFormatter.IsFormatterType(type))
                                    .Select(formatterType => new MetaFormatter(formatterType));

            foreach (MetaFormatter newMetaFormatter in newMetaFormatters)
            {
                RegisterFormatter(newMetaFormatter);
            }
        }