c# - Get static value from another class -


i have static string in class:

public static class someclass {     public static string mystring = "hello world"; } 

in t4 template file want invoke static variable conditional purposes in order generate someclass2. thought this:

<# someclass.mystring #> 

i tried multiple approaches, nothing seemed work. getting error someclass.mystring not exists. how can achieved?

as daniel spotted, trying self reference t4 template same project never built, someclass doesn't exist in (non existent?) assembly (if reference it)

you comment out t4 code build project , can reference

or alternatively put "helpers" in different project/assembly can reference from t4-project using 't4 assembly directive'

or put helpers inside t4 template

public static class fooorbar { public static string { { return  " <#= myhelpers.getstring(true) #> "; } } } <#+ public static class myhelpers {     public static string getstring(bool what)     {         return ? "foo" : "bar";     } } #> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -