Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / NewGenerator / Castle.NewGenerator.VSNetIntegration / VSGeneratorService.cs
blob661ed36ad771932093abc01f755d292b406c12a4
1 namespace Castle.NewGenerator.VSNetIntegration
3 using System;
4 using System.ComponentModel;
5 using System.Reflection;
6 using System.Runtime.InteropServices;
7 using Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine;
8 using Castle.NewGenerator.Core;
9 using Castle.NewGenerator.Core.MR;
10 using EnvDTE;
12 [Guid("9FF77D9F-E4FC-47EE-8E8B-0079FC2F247D")]
13 [ProgId("Castle.TestWizard")]
14 [ComDefaultInterface(typeof(IDTWizard))]
15 [ComVisible(true)]
16 public class VSGeneratorService : DefaultGeneratorService, IDTWizard
18 public VSGeneratorService() : base(null, null)
22 public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams,
23 ref wizardResult retval)
25 DTE dte = (DTE) Application;
27 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
29 string workingDir = (string) ContextParams[3];
30 string templateDir = @"C:\dev\DotNet\castle\svn\trunk\MonoRail\NewGenerator\GeneratorTemplates\";
32 context = new GeneratorContext(workingDir, templateDir);
34 //Using NVelocityTemplateEngine. Since we must resolve the lib dir...
35 templateEngine = new NVelocityTemplateEngine(templateDir);
36 ((ISupportInitialize) templateEngine).BeginInit();
38 NewProject generator = CreateNewProject(ContextParams);
40 generator.Generate(context, this);
42 dte.Solution.Open(generator.SolutionFilePath);
45 private static NewProject CreateNewProject(object[] contextParams)
47 NewProject gen = new NewProject();
49 gen.SolutionName = (string) contextParams[5];
50 gen.Name = (string) contextParams[1];
51 gen.SolutionFolder = ((string) contextParams[2]).Replace("\\"+ gen.Name, "");
53 return gen;
56 static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
58 // C:\dev\castle\svn\trunk\build\net-2.0\debug
59 return Assembly.LoadFile(@"C:\dev\DotNet\castle\svn\trunk\build\net-2.0\debug\" + args.Name);