Created
June 22, 2013 05:22
-
-
Save kazuk/5835964 to your computer and use it in GitHub Desktop.
プロジェクトのマニフェストリソース名を T4MVC っぽく
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="true" language="C#" #> | |
<#@ assembly name="$(TargetPath)" #> | |
<#@ assembly name="System.Core" #> | |
<#@ assembly name="EnvDTE" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="EnvDTE" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ output extension=".cs" #> | |
<# | |
var hostServiceProvider = Host as IServiceProvider; | |
var dte = (DTE) hostServiceProvider.GetService(typeof(DTE)); | |
var solution = dte.Solution; | |
var projItem = solution.FindProjectItem( Host.TemplateFile ); | |
var project = projItem.ContainingProject; | |
string namespaceName = (string) project.Properties.Item("RootNamespace").Value; | |
string assemblyName = (string) project.Properties.Item("AssemblyName").Value; | |
var sourceAssembly = AppDomain.CurrentDomain.GetAssemblies() | |
.Single( a=>a.GetName().Name==assemblyName ); | |
#> | |
namespace <#=namespaceName#> | |
{ | |
// ReSharper disable InconsistentNaming | |
public static class ManifestResourceNames | |
{ | |
<# | |
foreach( var item in sourceAssembly.GetManifestResourceNames() ) | |
{ | |
#> | |
public const string <#=item.Replace(".","_")#>="<#=item#>"; | |
<# | |
} | |
#> | |
} | |
// ReSharper enable InconsistentNaming | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment