<br><font size=2 face="sans-serif">Dear Jim,</font>
<br>
<br><font size=2 face="sans-serif">this is quite easy to achieve using
an "embedded ressource" for the template. Add the file in VS
to your project and select "Embedded Resource" as a build option
in the properties of the file.</font>
<br>
<br><font size=2 face="sans-serif">In your code, you can use something
like this:</font>
<br>
<br><font size=2 face="sans-serif"> private
StringTemplateGroup GetTemplateFromResource( string resource )</font>
<br><font size=2 face="sans-serif"> {</font>
<br><font size=2 face="sans-serif">
StringTemplateGroup group = null;</font>
<br><font size=2 face="sans-serif">
Assembly assembly = Assembly.GetExecutingAssembly();</font>
<br><font size=2 face="sans-serif">
Stream stream = assembly.GetManifestResourceStream( resource );</font>
<br>
<br><font size=2 face="sans-serif">
if( stream != null )</font>
<br><font size=2 face="sans-serif">
{</font>
<br><font size=2 face="sans-serif">
var reader = new StreamReader( stream );</font>
<br><font size=2 face="sans-serif">
group = new StringTemplateGroup( reader );</font>
<br><font size=2 face="sans-serif">
}</font>
<br><font size=2 face="sans-serif"> // else: template not
found !</font>
<br><font size=2 face="sans-serif">
return group;</font>
<br><font size=2 face="sans-serif"> }</font>
<br>
<br><font size=2 face="sans-serif">The resource parameter is the fully
qualified name of the embedded resource, e.g. "Xyz.Template.stg"
if Xyz is the standard namespace of the project and Template.stg is the
name of the template file. Be aware that you need to recompile when changing
the template.</font>
<br><font size=2 face="sans-serif"><br>
Freundliche Grüße / Best Regards<br>
Lars von Wedel<br>
_________________________________________<br>
<br>
Bayer Technology Services GmbH<br>
BTS-PT-PD-ES<br>
Leverkusen, E 41<br>
Phone: +49 214 30 56456<br>
Fax: +49 214 30 62677<br>
E-mail: lars.vonwedel@bayertechnology.com<br>
Web: www.bayertechnology.com<br>
<br>
Geschäftsführer: Achim Noack<br>
Aufsichtsratsvorsitzender: Dr. Wolfgang Plischke<br>
Sitz der Gesellschaft: Leverkusen | Eintragung: Amtsgericht
Köln, HRB 49896<br>
</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>"Jim Idle" <jimi@temporal-wave.com></b>
</font>
<br><font size=1 face="sans-serif">Gesendet von: stringtemplate-interest-bounces@antlr.org</font>
<p><font size=1 face="sans-serif">07.10.2009 21:06</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">An</font></div>
<td><font size=1 face="sans-serif">"stringtemplate-interest@antlr.org"
<stringtemplate-interest@antlr.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Kopie</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Thema</font></div>
<td><font size=1 face="sans-serif">[stringtemplate-interest] Packaging
C# StringTemplate in an assembly</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3 face="Calibri">So I can’t find any example (maybe I am
blind) of how to add a .stg file into my C# project so that it goes in
to the assembly and can be loaded at runtime. Anyone got an example of
loading from the .Net assembly?</font>
<br><font size=3 face="Calibri"> </font>
<br><font size=3 face="Calibri">Cheers,</font>
<br><font size=3 face="Calibri"> </font>
<br><font size=3 face="Calibri">Jim</font><tt><font size=2>_______________________________________________<br>
stringtemplate-interest mailing list<br>
stringtemplate-interest@antlr.org<br>
http://www.antlr.org/mailman/listinfo/stringtemplate-interest<br>
</font></tt>
<br>