コード例 #1
0
        public virtual T RunParser <T>(string source, Document doc) where T : IAst
        {
            var type      = typeof(T);
            var parserObj = default(Object);

            if (!BuilderInstances.TryGetValue(type, out parserObj))
            {
                throw new ElideException("Unable to find parser for '{0}'.", type);
            }

            var parser = (ICodeParser <T>)parserObj;

            parser.App = App;
            return(RunParser(source, doc, parser));
        }
コード例 #2
0
        public virtual T RunBuilder <T>(string source, Document doc, BuildOptions options, params ExtendedOption[] extOptions) where T : ICompiledAssembly
        {
            var type       = typeof(T);
            var builderObj = default(Object);

            if (!BuilderInstances.TryGetValue(type, out builderObj))
            {
                throw new ElideException("Unable to find builder for '{0}'.", type);
            }

            var builder = (ICodeBuilder <T>)builderObj;

            builder.App = App;
            return(RunBuilder(source, doc, options, builder, extOptions));
        }
コード例 #3
0
        public override void Initialize(IApp app)
        {
            base.Initialize(app);

            Parsers.ForEach(b =>
            {
                var iface = default(Type);

                if ((iface = b.Type.GetInterface(typeof(ICodeParser <>).FullName)) == null)
                {
                    throw new ElideException("Parser '{0}' doesn't implement ICodeParser<> interface.", b.Type);
                }

                var arg = iface.GetGenericArguments()[0];
                BuilderInstances.Add(arg, TypeCreator.New(b.Type));
            });
        }