How to create our own Custom Expression Builders ?
SOLUTION:
using System;
using System.Web.UI;
using System.Web.Compilation;
using System.CodeDom;
public class VersionExpressionBuilder : ExpressionBuilder
{
public override CodeExpression GetCodeExpressionBoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
string param = entry.Expression;
if (String.Compare(param, "All", true) == 0)
return new CodePrimitiveExpression
(String.Format("{0}.{1}.{2}.{3}", Environment.Version.Major,Environment.Version.Minor, Environment.Version.Build,Environment.Version.Revision));
else if (String.Compare(param, "MajorMinor", true) == 0)
return new CodePrimitiveExpression
(String.Format("{0}.{1}", Environment.Version.Major, Environment.Version.Minor));
else throw new InvalidOperationException
("Use $ Version:All or $ Version:MajorMinor"); }}
No comments:
Post a Comment