コード例 #1
0
        private static Type GetSolutionWriterImplementation(string format)
        {
            Assembly assembly = typeof(Driver).Assembly;

            foreach (Type type in assembly.GetTypes())
            {
                if (type.GetInterface(typeof(SolutionWriter).FullName) != null)
                {
                    OutputFormatAttribute outputFormat = Attribute.GetCustomAttribute(type, typeof(OutputFormatAttribute)) as OutputFormatAttribute;

                    if (outputFormat != null && outputFormat.Name == format)
                    {
                        return(type);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        public static IList GetOutputFormats()
        {
            ArrayList outputFormats = new ArrayList();

            Assembly assembly = typeof(Driver).Assembly;

            foreach (Type type in assembly.GetTypes())
            {
                if (type.GetInterface(typeof(SolutionWriter).FullName) != null)
                {
                    OutputFormatAttribute outputFormat = Attribute.GetCustomAttribute(type, typeof(OutputFormatAttribute)) as OutputFormatAttribute;

                    if (outputFormat != null)
                    {
                        outputFormats.Add(outputFormat.Name);
                    }
                }
            }

            outputFormats.Sort();

            return(outputFormats);
        }