本文整理汇总了C#中System.Linq.Expressions.NewExpression.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# NewExpression.ToString方法的具体用法?C# NewExpression.ToString怎么用?C# NewExpression.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.NewExpression
的用法示例。
在下文中一共展示了NewExpression.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitNew
internal override NewExpression VisitNew(NewExpression nex)
{
// Allow creation of DataServiceCollection<T> objects in projections
if (ResourceBinder.PatternRules.MatchNewDataServiceCollectionOfT(nex))
{
// It doesn't matter if the DSC is being tracked or not, that has no direct effect on the projections
// But it does matter if the T in DSC<T> is an entity or not. In here we only allow entity types to be used
// for creation of DSC.
if (ClientType.CheckElementTypeIsEntity(nex.Type))
{
foreach (Expression e in nex.Arguments)
{
// no need to check the constant values here (DataServiceContext, funcs, etc).
if (e.NodeType != ExpressionType.Constant)
{
base.Visit(e);
}
}
return nex;
}
}
throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjectionToEntity(this.type, nex.ToString()));
}
示例2: VisitNew
internal override NewExpression VisitNew(NewExpression nex)
{
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.ALinqExpressionNotSupportedInProjectionToEntity, this.type, nex.ToString()));
}
示例3: VisitNew
internal override NewExpression VisitNew(NewExpression nex)
{
if (ClientTypeUtil.TypeOrElementTypeIsEntity(nex.Type) && !ResourceBinder.PatternRules.MatchNewDataServiceCollectionOfT(nex))
{
throw new NotSupportedException(System.Data.Services.Client.Strings.ALinq_ExpressionNotSupportedInProjection(this.type, nex.ToString()));
}
return base.VisitNew(nex);
}
示例4: VisitNew
private void VisitNew(NewExpression node)
{
_constructor = node.Constructor;
var type = node.Type;
foreach (var parameter in node.Constructor.GetParameters())
{
MemberInfo member;
if (node.Members != null)
{
// anonymous types will have this set...
member = node.Members[parameter.Position];
}
else
{
var members = type.GetMember(
parameter.Name,
MemberTypes.Field | MemberTypes.Property,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
if (members.Length != 1)
{
var message = string.Format("Could not find a member match for constructor parameter {0} on type {1} in the expression tree {2}.",
parameter.Name,
type.Name,
node.ToString());
throw new NotSupportedException(message);
}
member = members[0];
}
_mappings.Add(new ProjectionMemberMapping
{
Expression = node.Arguments[parameter.Position],
Member = member,
Parameter = parameter
});
}
}
示例5: GetNew
private void GetNew(NewExpression newExpression)
{
foreach (var argument in newExpression.Arguments)
{
GetOperandValue();
}
var args = newExpression.Arguments;
var members = newExpression.Members;
if (newExpression.Type != lambdaExpression.Body.Type)
{
var lambdaHandler = new LambdaExpressionHandler(indentLevel + 1,
Expression.Lambda(newExpression,
Expression.Parameter(
lambdaExpression.Parameters[0].Type,
"source")));
foreach (var column in lambdaHandler.aliases)
{
aliases[lambaExpressionId + "." + column.Key] = column.Value;
aliases[column.Key] = column.Value;
}
}
else
{
for (int i = 0; i < args.Count; i++)
{
if (args[i].NodeType != ExpressionType.MemberAccess ||
//hack - should check if MemberAccess has a corresponding column
// in db
!(args[i].Type.IsValueType || args[i].Type == typeof(string)))
{
continue;
}
string memberName = null;
if (newExpression.Members[i].Name.StartsWith("get_"))
{
memberName = newExpression.Members[i].Name.Substring(4);
}
else
{
memberName = newExpression.Members[i].Name;
}
var key = lambaExpressionId + "." + memberName;
aliases[key] = GetHashedName((args[i] as MemberExpression));
}
}
terms.Push(Expression.Constant(
new BoxedConstant(newExpression.ToString())));
}