本文整理汇总了C#中System.Web.Compilation.ExpressionBuilderContext类的典型用法代码示例。如果您正苦于以下问题:C# ExpressionBuilderContext类的具体用法?C# ExpressionBuilderContext怎么用?C# ExpressionBuilderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpressionBuilderContext类属于System.Web.Compilation命名空间,在下文中一共展示了ExpressionBuilderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
if (!entry.Expression.Contains(","))
{
throw new ArgumentException("Must include two numbers separated by a comma.");
}
else
{
// get two numbers
string[] numbers = entry.Expression.Split(',');
if (numbers.Length != 2)
{
throw new ArgumentException("Only include two numbers");
}
else
{
int lowerLimit, upperLimit;
if (Int32.TryParse(numbers[0], out lowerLimit) && Int32.TryParse(numbers[1], out upperLimit))
{
CodeTypeReferenceExpression typeRef = new CodeTypeReferenceExpression(this.GetType());
CodeExpression[] methodParameters = new CodeExpression[2];
methodParameters[0] = new CodePrimitiveExpression(lowerLimit);
methodParameters[1] = new CodePrimitiveExpression(upperLimit);
return new CodeMethodInvokeExpression(typeRef, "GetRandomNumber", methodParameters);
}
else
{
throw new ArgumentException("Use valid Integers");
}
}
}
}
示例2: EvaluateExpression
public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
var fields = parsedData as ResourceExpressionFields;
EnsureResourceProviderFactory();
IResourceProvider provider = _resourceProviderFactory.CreateGlobalResourceProvider(fields.ClassKey);
return provider.GetObject(fields.ResourceKey, null);
}
示例3: ParseExpression
internal void ParseExpression(ExpressionBuilderContext context)
{
if (((this.Expression != null) && (this.ExpressionPrefix != null)) && (this.ExpressionBuilder != null))
{
this._parsedExpressionData = this.ExpressionBuilder.ParseExpression(this.Expression, base.Type, context);
}
}
示例4: GetResourceString
internal static string GetResourceString(HttpContextBase httpContext,
string expression,
string virtualPath,
object[] args)
{
ExpressionBuilderContext context = new ExpressionBuilderContext(virtualPath);
ResourceExpressionBuilder builder = new ResourceExpressionBuilder();
ResourceExpressionFields fields = (ResourceExpressionFields) builder
.ParseExpression(expression,
typeof (string), context);
if (!string.IsNullOrEmpty(fields.ClassKey))
return string.Format((string) httpContext.GetGlobalResourceObject(
fields.ClassKey,
fields.ResourceKey,
CultureInfo.CurrentUICulture),
args);
return string.Format((string) httpContext.GetLocalResourceObject(
virtualPath,
fields.ResourceKey,
CultureInfo.CurrentUICulture),
args);
}
示例5: GetCodeExpression
/// <summary>
/// Gets the code expression.
/// </summary>
/// <param name="entry">
/// The entry.
/// </param>
/// <param name="parsedData">
/// The parsed data.
/// </param>
/// <param name="context">
/// The context.
/// </param>
/// <returns>
/// A CodeExpression.
/// </returns>
public override CodeExpression GetCodeExpression(
BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
var typeName = BeforeLast(entry.Expression, ".");
var propertyName = AfterLast(entry.Expression, ".");
return new CodePrimitiveExpression(PropertyLength(typeName, propertyName));
}
示例6: EvaluateExpression
public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
if (target is Control)
{
return GetRouteValue(context.TemplateControl.Page, entry.Expression.Trim(), entry.ControlType, entry.Name);
}
return null;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RouteValueExpressionBuilder.cs
示例7: GetCodeExpression
public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
return new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(typeof(WebManager) ),
"GetService",
new CodePrimitiveExpression( entry.Expression.Trim() ),
new CodeTypeOfExpression( new CodeTypeReference(entry.PropertyInfo.PropertyType ) ) );
}
示例8: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
if ((entry.DeclaringType == null) || (entry.PropertyInfo == null))
{
return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()) });
}
return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()), new CodeTypeOfExpression(entry.DeclaringType), new CodePrimitiveExpression(entry.PropertyInfo.Name) });
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:AppSettingsExpressionBuilder.cs
示例9: GetCodeExpression
public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
return new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(typeof(WebManager) ),
"GetLabel",
new CodePrimitiveExpression( entry.Expression.Trim() ),
new CodePrimitiveExpression( context.VirtualPath ));
}
示例10: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
string property = (string) parsedData;
CodePrimitiveExpression prim = new CodePrimitiveExpression(property);
CodeExpression[] args = new[] {prim};
CodeTypeReferenceExpression refType = new CodeTypeReferenceExpression(this.GetType());
return new CodeMethodInvokeExpression(refType, "GetProperty", args);
}
示例11: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
object parsedData, ExpressionBuilderContext context) {
return new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(this.GetType()),
"GetRouteUrl",
new CodeThisReferenceExpression(),
new CodePrimitiveExpression(entry.Expression.Trim()));
}
示例12: GetCodeExpression
public override CodeExpression GetCodeExpression(
BoundPropertyEntry entry,
object parsedData,
ExpressionBuilderContext context)
{
CodeMethodInvokeExpression ex = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(ResourceReader)),
"GetVal", new CodePrimitiveExpression(entry.Expression.ToString().Trim()));
return ex;
}
示例13: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
ResourceExpressionFields fields = (ResourceExpressionFields) parsedData;
if (fields.ClassKey.Length == 0)
{
return this.GetPageResCodeExpression(fields.ResourceKey, entry);
}
return this.GetAppResCodeExpression(fields.ClassKey, fields.ResourceKey, entry);
}
示例14: GetCodeExpression
public override CodeExpression GetCodeExpression (BoundPropertyEntry entry, object parsedData,
ExpressionBuilderContext context)
{
Pair connString = parsedData as Pair;
return new CodeMethodInvokeExpression (
new CodeTypeReferenceExpression (typeof (ConnectionStringsExpressionBuilder)),
(bool)connString.Second ? "GetConnectionStringProviderName" : "GetConnectionString",
new CodeExpression [] {new CodePrimitiveExpression (connString.First)}
);
}
示例15: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
Pair pair = (Pair) parsedData;
string first = (string) pair.First;
if ((bool) pair.Second)
{
return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetConnectionString", new CodeExpression[] { new CodePrimitiveExpression(first) });
}
return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetConnectionStringProviderName", new CodeExpression[] { new CodePrimitiveExpression(first) });
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ConnectionStringsExpressionBuilder.cs