当前位置: 首页>>代码示例>>C#>>正文


C# ILanguage.Initialize方法代码示例

本文整理汇总了C#中ILanguage.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ILanguage.Initialize方法的具体用法?C# ILanguage.Initialize怎么用?C# ILanguage.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILanguage的用法示例。


在下文中一共展示了ILanguage.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Template

 /// <summary>
 ///     Initializes a new instance of a <c>Template</c> type and compiles the
 ///     user code if possible.
 /// </summary>
 /// <param name="templateString">
 ///     A template String. Can't be empty. Can contain user text and/or code.
 ///     User's code must be limited with special code brackets <c>&lt;% ... %&gt;</c>.
 ///     Correct template String examples:
 ///     <example>
 ///         This template String will be treated as a text.
 ///         <code>
 ///             "This text will be printed as is"
 ///         </code>
 ///     </example>
 ///     <example>
 ///         But this one will be treated as a code, that should be executed.
 ///         <code>
 ///             "&lt;%int n = 5; output.Write(5);%&gt;"
 ///         </code>
 ///     </example>
 ///     You can combine text and code in a template String like this
 ///     <example>
 ///         <code>
 ///             "Hello, &lt;%output.Write("World")%&gt;!"
 ///         </code>
 ///     </example>
 ///     Code brackets can't be nested, otherwise <see cref="IncorrectSyntaxException">
 ///     will be thrown. You shouldn't use "$lt;%" and "%&gt;" 
 /// </param>
 /// <param name="namespaces">
 ///     It's a String[] array, that can contain required for code execution namespaces. 
 ///     Can be null.
 ///     <example>
 ///         <code>
 ///             new String[] { "System.Linq", "System.Threading.Tasks" }
 ///         </code>
 ///     </example>
 /// </param>
 /// <param name="assemblies">
 ///     It's a String[] array, that can contain required for code execution assemblies. 
 ///     Can be null.
 ///     <example>
 ///         <code>
 ///             new String[] { "System.Core.dll" }
 ///         </code>
 ///     </example>
 /// </param>
 /// <param name="language">
 ///     Some <see cref="ILanguage"/> implementation should be passed 
 ///     in order to execute user code. 
 ///     <c>Can't be null.</c>
 /// </param>
 /// <exception cref="ArgumentNullException">
 ///     If <paramref name="templateString"/> or
 ///     <paramref name="language"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="IncorrectSyntaxException">
 ///     If <paramref name="templateString"/> has incorrect synatax.
 /// </exception>
 public Template(String templateString, String[] namespaces, String[] assemblies, ILanguage language)
 {
     if (templateString == null)
     {
         throw new ArgumentNullException("templateString");
     }
     if (language == null)
     {
         throw new ArgumentNullException("language");
     }
     this.language = language;
     var templateParser = new TemplateParser(language);
     String templateCode = templateParser.Parse(templateString);
     language.Initialize(templateCode, namespaces, assemblies);
 }
开发者ID:kiryl-t,项目名称:itran-template,代码行数:74,代码来源:Template.cs


注:本文中的ILanguage.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。