Exemple #1
0
        private static GrammarItemList LoadGrammars(string assemblyPath)
        {
            Assembly asm = null;

            try {
                asm = GrammarLoader.LoadAssembly(assemblyPath);
            } catch (Exception ex) {
                MessageBox.Show("Failed to load assembly: " + ex.Message);
                return(null);
            }
            var types    = asm.GetTypes();
            var grammars = new GrammarItemList();

            foreach (Type t in types)
            {
                if (t.IsAbstract)
                {
                    continue;
                }
                if (!t.IsSubclassOf(typeof(Grammar)))
                {
                    continue;
                }
                grammars.Add(new GrammarItem(t, assemblyPath));
            }
            if (grammars.Count == 0)
            {
                MessageBox.Show("No classes derived from Irony.Grammar were found in the assembly.");
                return(null);
            }
            return(grammars);
        }