<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 &quot;embedded ressource&quot; for the template. Add the file in VS
to your project and select &quot;Embedded Resource&quot; 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">&nbsp; &nbsp; &nbsp; &nbsp; private
StringTemplateGroup GetTemplateFromResource( string resource )</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
StringTemplateGroup group = null;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Assembly assembly = Assembly.GetExecutingAssembly();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Stream stream = assembly.GetManifestResourceStream( resource );</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
if( stream != null )</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
{</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; var reader = new StreamReader( stream );</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; group = new StringTemplateGroup( reader );</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
}</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; // else: template not
found !</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
return group;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="sans-serif">The resource parameter is the fully
qualified name of the embedded resource, e.g. &quot;Xyz.Template.stg&quot;
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 &nbsp; | &nbsp; 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>&quot;Jim Idle&quot; &lt;jimi@temporal-wave.com&gt;</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">&quot;stringtemplate-interest@antlr.org&quot;
&lt;stringtemplate-interest@antlr.org&gt;</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&#8217;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">&nbsp;</font>
<br><font size=3 face="Calibri">Cheers,</font>
<br><font size=3 face="Calibri">&nbsp;</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>