Esempio n. 1
0
        public override void Initialize(IApp app)
        {
            base.Initialize(app);

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

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

                var arg = iface.GetGenericArguments()[0];
                RunnerInstances.Add(arg, TypeCreator.New(b.Type));
            });
        }
Esempio n. 2
0
        public virtual bool RunCode <T>(T compiled, ExecOptions options, params ExtendedOption[] extOptions) where T : ICompiledAssembly
        {
            var type      = typeof(T);
            var runnerObj = default(Object);

            if (type == typeof(ICompiledAssembly))
            {
                type = compiled.GetType();
            }

            if (!RunnerInstances.TryGetValue(type, out runnerObj))
            {
                throw new ElideException("Unable to find runner for '{0}'.", type);
            }

            var runner = (ICodeRunner <T>)runnerObj;

            runner.App = App;
            return(Run(compiled, options, runner, extOptions));
        }