[bistro-framework] r461 committed - Templates feature - Added wizard class to set references' paths in tem...

0 views
Skip to first unread message

codesite...@google.com

unread,
May 27, 2010, 1:27:04 PM5/27/10
to bistro-d...@googlegroups.com
Revision: 461
Author: sasha_...@mail.ru
Date: Thu May 27 10:26:35 2010
Log: Templates feature - Added wizard class to set references' paths in
templates when a project is created from the template.In VS2008 assembly
should be added to PublicAssemblies folder of the IDE.
http://code.google.com/p/bistro-framework/source/detail?r=461

Added:
/Bistro/trunk/Bistro.Designer/Templates/ReferenceWizard.cs
Modified:
/Bistro/trunk/Bistro.Designer/Bistro.Designer2008.csproj
/Bistro/trunk/Bistro.Designer/Bistro.Designer2008.sln
/Bistro/trunk/Bistro.Designer/BistroDesigner2010.csproj
/Bistro/trunk/Bistro.Designer/Projects/FSharp/ProjectManager.cs
/Bistro/trunk/Bistro.Designer/Properties/AssemblyInfo.cs

=======================================
--- /dev/null
+++ /Bistro/trunk/Bistro.Designer/Templates/ReferenceWizard.cs Thu May 27
10:26:35 2010
@@ -0,0 +1,98 @@
+using System;
+using System.Text;
+using System.IO;
+using System.Xml;
+using System.Windows.Forms;
+using Microsoft.Win32;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.TemplateWizard;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
+
+namespace BistroTemplates
+{
+ public class ReferenceWizard: IWizard
+ {
+ #region IWizard Members
+#if VS2008
+ private const string NDJANGODIR = "[NDJANGODIR35]";
+#elif VS2010
+ private const string NDJANGODIR = "[NDJANGODIR40]";
+#endif
+ private const string BISTRODIR = "[BISTRODIR]";
+ IVsSolution sln;
+ string fileName;
+ EnvDTE.DTE dte;
+
+ public void BeforeOpeningFile(EnvDTE.ProjectItem projectItem)
+ {
+ }
+
+ public void ProjectFinishedGenerating(EnvDTE.Project project)
+ {
+ fileName = project.FullName;
+
+ }
+
+ public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem
projectItem)
+ {
+ }
+
+ public void RunFinished()
+ {
+
+ sln =
((IVsSolution)Package.GetGlobalService(typeof(SVsSolution)));
+ ServiceProvider serviceProvider = new ServiceProvider(dte as
Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
+ string projectGuid = null;
+ using (XmlReader projectReader = XmlReader.Create(fileName))
+ {
+ projectReader.MoveToContent();
+ object nodeName =
projectReader.NameTable.Add("ProjectGuid");
+ while (projectReader.Read())
+ {
+ if (Object.Equals(projectReader.LocalName, nodeName))
+ {
+ projectGuid =
projectReader.ReadElementContentAsString();
+ break;
+ }
+ }
+ }
+ IVsHierarchy hier =
VsShellUtilities.GetHierarchy(serviceProvider, new Guid(projectGuid));
+
sln.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject,
hier, 0);
+ String bistroPath =
(String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\Bistro").GetValue("InstallDir");
+#if VS2008
+ String ndjangoPath =
(String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\NDjango").GetValue("InstallDir2008");
+#elif VS2010
+ String ndjangoPath =
(String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\NDjango").GetValue("InstallDir2010");
+#endif
+ StreamReader reader = new StreamReader(fileName);
+ string content = reader.ReadToEnd();
+ reader.Close();
+ content = content.Replace(BISTRODIR, (bistroPath == null) ?
BISTRODIR : Path.GetFullPath(bistroPath)).
+ Replace(NDJANGODIR, (ndjangoPath == null) ? NDJANGODIR :
Path.GetFullPath(ndjangoPath));
+ StreamWriter sw = new StreamWriter(fileName);
+ sw.Write(content);
+ sw.Close();
+ IntPtr ppProject = IntPtr.Zero;
+ Guid guid1 = new Guid();
+ Guid guid2 = new Guid();
+ sln.CreateProject(ref guid1, fileName, null, null,
(uint)__VSCREATEPROJFLAGS.CPF_OPENFILE, ref guid2, out ppProject);
+
+
+ }
+
+ public void RunStarted(object automationObject,
System.Collections.Generic.Dictionary<string, string>
replacementsDictionary, WizardRunKind runKind, object[] customParams)
+ {
+ dte = automationObject as EnvDTE.DTE;
+ }
+
+ public bool ShouldAddProjectItem(string filePath)
+ {
+ return true;
+ }
+
+ #endregion
+ }
+}
=======================================
--- /Bistro/trunk/Bistro.Designer/Bistro.Designer2008.csproj Fri May 21
08:07:52 2010
+++ /Bistro/trunk/Bistro.Designer/Bistro.Designer2008.csproj Thu May 27
10:26:35 2010
@@ -8,7 +8,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Bistro.Designer</RootNamespace>
<AssemblyName>Bistro.Designer2008</AssemblyName>
- <SignAssembly>False</SignAssembly>
+ <SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ProjectGuid>{7C11A46D-27A6-41F9-A754-0D9F1DA4369D}</ProjectGuid>
@@ -79,6 +79,7 @@
<Reference Include="Microsoft.VisualStudio.ManagedInterfaces" />
<Reference Include="Microsoft.VisualStudio.ProjectAggregator,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Design,
Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.TemplateWizardInterface,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.VSHelp, Version=7.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Designer.Interfaces" />
<Reference Include="Microsoft.VisualStudio.OLE.Interop" />
@@ -261,6 +262,7 @@
<Compile Include="ProjectBase\VsCommands.cs" />
<Compile Include="ProjectBase\VSShellUtilities.cs" />
<Compile Include="Projects\FSharp\ProjectManager.cs" />
+ <Compile Include="Templates\ReferenceWizard.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources.resx">
=======================================
--- /Bistro/trunk/Bistro.Designer/Bistro.Designer2008.sln Fri May 21
08:07:52 2010
+++ /Bistro/trunk/Bistro.Designer/Bistro.Designer2008.sln Thu May 27
10:26:35 2010
@@ -3,8 +3,6 @@
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "Bistro.Designer2008", "Bistro.Designer2008.csproj", "{7C11A46D-27A6-41F9-A754-0D9F1DA4369D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "ProjectExtender", "..\ProjectExtender\ProjectExtender.csproj", "{C085BF9A-0393-4D2C-8EAE-7BA0ED1EEB09}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,10 +13,6 @@
{7C11A46D-27A6-41F9-A754-0D9F1DA4369D}.Debug|Any CPU.Build.0 = Debug|Any
CPU
{7C11A46D-27A6-41F9-A754-0D9F1DA4369D}.Release|Any CPU.ActiveCfg =
Release|Any CPU
{7C11A46D-27A6-41F9-A754-0D9F1DA4369D}.Release|Any CPU.Build.0 = Release|
Any CPU
- {C085BF9A-0393-4D2C-8EAE-7BA0ED1EEB09}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
- {C085BF9A-0393-4D2C-8EAE-7BA0ED1EEB09}.Debug|Any CPU.Build.0 = Debug|Any
CPU
- {C085BF9A-0393-4D2C-8EAE-7BA0ED1EEB09}.Release|Any CPU.ActiveCfg =
Release|Any CPU
- {C085BF9A-0393-4D2C-8EAE-7BA0ED1EEB09}.Release|Any CPU.Build.0 = Release|
Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
=======================================
--- /Bistro/trunk/Bistro.Designer/BistroDesigner2010.csproj Fri May 21
08:07:52 2010
+++ /Bistro/trunk/Bistro.Designer/BistroDesigner2010.csproj Thu May 27
10:26:35 2010
@@ -59,6 +59,7 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0" />
+ <Reference Include="Microsoft.VisualStudio.TemplateWizardInterface,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.10.0">
<Private>false</Private>
@@ -146,6 +147,7 @@
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PkgCmdID.cs" />
+ <Compile Include="Templates\ReferenceWizard.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="C:\Program Files\Microsoft Visual Studio 2010
SDK\VisualStudioIntegration\Common\Source\CSharp\RegistrationAttributes\WebSiteProjectAttribute.cs">
=======================================
--- /Bistro/trunk/Bistro.Designer/Projects/FSharp/ProjectManager.cs Fri May
21 08:07:52 2010
+++ /Bistro/trunk/Bistro.Designer/Projects/FSharp/ProjectManager.cs Thu May
27 10:26:35 2010
@@ -9,7 +9,7 @@
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;

-using Bistro.Configuration;
+//using Bistro.Configuration;

using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants;
using Microsoft.VisualStudio.OLE.Interop;
=======================================
--- /Bistro/trunk/Bistro.Designer/Properties/AssemblyInfo.cs Fri May 21
08:07:52 2010
+++ /Bistro/trunk/Bistro.Designer/Properties/AssemblyInfo.cs Thu May 27
10:26:35 2010
@@ -29,7 +29,7 @@
// You can specify all the values or you can default the Revision and
Build Numbers
// by using the '*' as shown below:

-[assembly: AssemblyVersion("0.9.3.0")]
+[assembly: AssemblyVersion("0.9.3.1")]
[assembly: AssemblyFileVersion("0.9.3.1")]


Reply all
Reply to author
Forward
0 new messages