示例#1
0
        public static ArrayList GetCommandDescriptors(Type[] types)
        {
            ArrayList cmds = new ArrayList();
            ArrayList mdls = new ArrayList();

            //StringBuilder str = new StringBuilder();
            //str.AppendLine("-------------");
            //foreach (Type t in types)
            //{
            //    str.AppendLine("#" + t.FullName);
            //}
            //str.AppendLine("-------------");
            //MessageBox.Show(str.ToString());

            foreach (Type type in types)
            {
                if (type.IsSubclassOf(typeof(WriterCommand)) &&
                    type.Equals(typeof(WriterCommandDelegate)) == false)
                {
                    WriterCommandDescriptor cmd = WriterCommandDescriptor.Create(type, false);
                    if (cmd != null)
                    {
                        cmds.Add(cmd);
                    }
                }
                else if (type.IsSubclassOf(typeof(CSWriterCommandModule)))
                {
                    WriterCommandModuleDescriptor mdl = WriterCommandModuleDescriptor.Create(type, false);
                    if (mdl != null)
                    {
                        mdls.Add(mdl);
                    }
                }
            }
            cmds.Sort(new CommandDescriptorNameComparer());
            mdls.Sort(new CommandDescriptorNameComparer());
            ArrayList result = new ArrayList();

            result.AddRange(cmds);
            result.AddRange(mdls);

            return(result);
        }