public override void Setup()
        {
            base.Setup();

            var commands = new[]
            {
                new CommandDescriptor("IdentityRunnable", String.Empty, Enumerable.Empty<ArgumentDescriptor>(), new[] {"IdentityRunnable"}),
                new CommandDescriptor("IncrementRunnable", String.Empty, new[]
                {
                    new ArgumentDescriptor
                    {
                        ArgumentType = typeof (Double),
                        ArgumentName = "value",
                        DefaultValue = 0,
                        IsOptional = false,
                        Position = 0
                    }
                }, new[] {"IncrementRunnable", "increment", "inc"})
            };

            var runnableFactory = new DefaultRunnableFactory(new[] {typeof (IdentityRunnable), typeof (IncrementRunnable)});

            var repository = new MemoryDescriptorRepository(commandDescriptors: commands);
            var commandCallResolver = new DefaultCommandCallResolver(repository, runnableFactory);
            var selectorManager = new DefaultSelectorFactory();
            var nodeSelectorResolver = new DefaultSelectorResolver(selectorManager, repository);
            var runnableManager = new DefaultRunnableManager();
            var executor = new StandardExecutor(runnableManager);

            // initialize compiler and control flow factory
            ControlFlowFactory = new DefaultControlFlowFactory(commandCallResolver, nodeSelectorResolver, executor);
            Compiler = new CodeQueryCompiler();
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            stopwatch = new Stopwatch();

            var assemblies = new[] {Assembly.Load("CodeSharper.Core"), Assembly.Load("CodeSharper.Languages"), Assembly.Load("CodeSharper.Languages.CSharp"), Assembly.GetExecutingAssembly()};
            var runnableTypeResolver = new AutoRunnableResolver();
            var valueConverter = new IntegerValueConverter();
            var interactiveService = new ReplaceTextInteractiveService(this);

            var serviceFactory = new SimpleServiceFactory();
            serviceFactory.RegisterInteractiveService(interactiveService);

            var runnableFactory = new DefaultRunnableFactory(runnableTypeResolver.ResolveRunnableTypes(assemblies), valueConverter, serviceFactory: serviceFactory);
            var fileDescriptorRepository = new FileDescriptorRepository("descriptors.json", assemblies);
            var autoDescriptorRepository = new AutoCommandDescriptorRepository(assemblies.SelectMany(assembly => assembly.GetTypes()));
            var descriptorRepository = new MultiDescriptorRepository(
                Array<IDescriptorRepository>(fileDescriptorRepository, autoDescriptorRepository)
            );

            Bootstrapper = new Bootstrapper(runnableFactory, descriptorRepository);
            compilerModule = new TextCompilerModule(Bootstrapper);
        }