implemented visual basic code generation support
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
{
|
||||
public class CodeGeneratorFactory
|
||||
{
|
||||
public ICodeGenerator Create(string defaultNamespace, string inputFileContents)
|
||||
public ICodeGenerator Create(string defaultNamespace, string inputFileContents, CodeDomProvider codeDomProvider = null)
|
||||
{
|
||||
return new CodeDomCodeGenerator(new ResourceParser(inputFileContents), defaultNamespace);
|
||||
return new CodeDomCodeGenerator(new ResourceParser(inputFileContents), defaultNamespace, codeDomProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ReswCodeGen.CustomTool")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyTitle("ResW File Code Generator Custom Tool")]
|
||||
[assembly: AssemblyDescription("A Visual Studio 2012 Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ReswCodeGen.CustomTool")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012")]
|
||||
[assembly: AssemblyProduct("ResW File Code Generator Custom Tool")]
|
||||
[assembly: AssemblyCopyright("Copyright © Christian Resma Helle 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -32,5 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
<Compile Include="ResourceItem.cs" />
|
||||
<Compile Include="ResourceParser.cs" />
|
||||
<Compile Include="ReswFileCodeGenerator.cs" />
|
||||
<Compile Include="ReswFileCSharpCodeGenerator.cs" />
|
||||
<Compile Include="ReswFileVisualBasicCodeGenerator.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReswCodeGen.snk" />
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.CSharp;
|
||||
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
{
|
||||
[Guid("98983F6D-BC77-46AC-BA5A-8D9E8763F0D2")]
|
||||
[ComVisible(true)]
|
||||
public class ReswFileCSharpCodeGenerator : ReswFileCodeGenerator
|
||||
{
|
||||
public ReswFileCSharpCodeGenerator()
|
||||
: base(new CSharpCodeProvider())
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultExtension(out string pbstrDefaultExtension)
|
||||
{
|
||||
pbstrDefaultExtension = ".cs";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
@@ -6,19 +7,20 @@ using Microsoft.VisualStudio.Shell.Interop;
|
||||
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
{
|
||||
[Guid("98983F6D-BC77-46AC-BA5A-8D9E8763F0D2")]
|
||||
[ComVisible(true)]
|
||||
public class ReswFileCodeGenerator : IVsSingleFileGenerator
|
||||
public abstract class ReswFileCodeGenerator : IVsSingleFileGenerator
|
||||
{
|
||||
#region IVsSingleFileGenerator Members
|
||||
private readonly CodeDomProvider codeDomProvider;
|
||||
|
||||
public int DefaultExtension(out string pbstrDefaultExtension)
|
||||
protected ReswFileCodeGenerator(CodeDomProvider codeDomProvider)
|
||||
{
|
||||
pbstrDefaultExtension = ".cs";
|
||||
return 0;
|
||||
this.codeDomProvider = codeDomProvider;
|
||||
}
|
||||
|
||||
public int Generate(string wszInputFilePath,
|
||||
#region IVsSingleFileGenerator Members
|
||||
|
||||
public abstract int DefaultExtension(out string pbstrDefaultExtension);
|
||||
|
||||
public virtual int Generate(string wszInputFilePath,
|
||||
string bstrInputFileContents,
|
||||
string wszDefaultNamespace,
|
||||
IntPtr[] rgbOutputFileContents,
|
||||
@@ -28,11 +30,11 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
try
|
||||
{
|
||||
var factory = new CodeGeneratorFactory();
|
||||
var codeGenerator = factory.Create(wszDefaultNamespace, bstrInputFileContents);
|
||||
var codeGenerator = factory.Create(wszDefaultNamespace, bstrInputFileContents, codeDomProvider);
|
||||
var code = codeGenerator.GenerateCode();
|
||||
|
||||
var data = Encoding.UTF8.GetBytes(code);
|
||||
|
||||
|
||||
rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(data.Length);
|
||||
Marshal.Copy(data, 0, rgbOutputFileContents[0], data.Length);
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool
|
||||
{
|
||||
[Guid("704DB723-AB03-4369-A2D7-0C857E96C94C")]
|
||||
[ComVisible(true)]
|
||||
public class ReswFileVisualBasicCodeGenerator : ReswFileCodeGenerator
|
||||
{
|
||||
public ReswFileVisualBasicCodeGenerator()
|
||||
: base(new VBCodeProvider())
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultExtension(out string pbstrDefaultExtension)
|
||||
{
|
||||
pbstrDefaultExtension = ".vb";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user