Cosmos/source2/VSIP/Cosmos.VS.Package/FileGenerators/XSharpGenerator.cs
mterwoord_cp 0cd51f8c6b Add file generator for X# (empty for now)
add new projects to the source control mappings
2012-06-05 17:46:17 +00:00

44 lines
No EOL
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
using System.Runtime.InteropServices;
namespace Cosmos.VS.Package.FileGenerators
{
public class XSharpGenerator: IVsSingleFileGenerator
{
public int DefaultExtension(out string pbstrDefaultExtension)
{
pbstrDefaultExtension = ".xs";
return VSConstants.S_OK;
}
public int Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, IntPtr[] rgbOutputFileContents,
out uint pcbOutput, IVsGeneratorProgress pGenerateProgress)
{
var xGeneratedCode = DoGenerate(wszInputFilePath, bstrInputFileContents, wszDefaultNamespace);
var xBytes = Encoding.UTF8.GetBytes(xGeneratedCode);
if (xBytes.Length > 0)
{
rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(xBytes.Length);
Marshal.Copy(xBytes, 0, rgbOutputFileContents[0], xBytes.Length);
pcbOutput = (uint)xBytes.Length;
}
else
{
rgbOutputFileContents[0] = IntPtr.Zero;
pcbOutput = 0;
}
return VSConstants.S_OK;
}
private static string DoGenerate(string inputFileName, string inputFileContents, string defaultNamespace)
{
return "// generated content for: " + inputFileName;
}
}
}