Sarcasm.Reflection.MetaFormatter.IsFormatterType C# (CSharp) 메소드

IsFormatterType() 공개 정적인 메소드

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

Usage Example

예제 #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);
            }
        }