PageRenderTime 12ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/Compilation/CodeExpressionBuilder.cs

#
C# | 55 lines | 18 code | 4 blank | 33 comment | 0 complexity | a8c778b182e675fbbd148aecbcfcb660 MD5 | raw file
 1// --------------------------------------------------------------------------------------------------------------------
 2// <summary>
 3//   Code Expression Builder
 4// </summary>
 5// --------------------------------------------------------------------------------------------------------------------
 6
 7namespace BlogEngine.Core.Compilation
 8{
 9    using System.CodeDom;
10    using System.Web.Compilation;
11    using System.Web.UI;
12
13    /// <summary>
14    /// Code Expression Builder
15    /// </summary>
16    /// <example>
17    /// page.aspx:
18    ///     &lt;asp:CheckBox id="chk1" runat="server" Text='&lt;%$ code: DateTime.Now %&gt;' /&gt;
19    /// web.config:
20    ///     &lt;compilation debug="true"&gt;
21    ///         &lt;expressionBuilders&gt;
22    ///             &lt;add expressionPrefix="code" type="WebApp.Compilation.CodeExpressionBuilder, WebApp" /&gt;
23    ///         &lt;/expressionBuilders&gt;
24    ///     &lt;/compilation&gt;
25    /// </example>
26    [ExpressionPrefix("Code")]
27    [ExpressionEditor("BlogEngine.Core.Compilation.Design.CodeExpressionEditor, BlogEngine.Core")]
28    public class CodeExpressionBuilder : ExpressionBuilder
29    {
30        #region Public Methods
31
32        /// <summary>
33        /// When overridden in a derived class, returns code that is used during page execution to obtain the evaluated expression.
34        /// </summary>
35        /// <param name="entry">
36        /// The object that represents information about the property bound to by the expression.
37        /// </param>
38        /// <param name="parsedData">
39        /// The object containing parsed data as returned by <see cref="M:System.Web.Compilation.ExpressionBuilder.ParseExpression(System.String,System.Type,System.Web.Compilation.ExpressionBuilderContext)"/>.
40        /// </param>
41        /// <param name="context">
42        /// Contextual information for the evaluation of the expression.
43        /// </param>
44        /// <returns>
45        /// A <see cref="T:System.CodeDom.CodeExpression"/> that is used for property assignment.
46        /// </returns>
47        public override CodeExpression GetCodeExpression(
48            BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
49        {
50            return new CodeSnippetExpression(entry.Expression.Trim());
51        }
52
53        #endregion
54    }
55}