本文整理汇总了C#中System.Linq.Expressions.ElementInit类的典型用法代码示例。如果您正苦于以下问题:C# ElementInit类的具体用法?C# ElementInit怎么用?C# ElementInit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElementInit类属于System.Linq.Expressions命名空间,在下文中一共展示了ElementInit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
private void Initialize(ElementInit elementInit)
{
if (elementInit == null) throw new ArgumentNullException("elementInit");
AddMethod = new MethodInfoNode(Context, elementInit.AddMethod);
Arguments = new ExpressionNodeList(Context, elementInit.Arguments);
}
示例2: VisitElementInit
protected override ElementInit VisitElementInit(ElementInit node)
{
var args = Visit(node.Arguments);
foreach(var arg in args)
AddParameter(arg);
return null;
}
示例3: ElementInit
void ElementInit(ElementInit elementInit)
{
indent++;
Write("Arguments:");
foreach (var argument in elementInit.Arguments) {
Expression(argument);
}
indent--;
}
示例4: EditableElementInit
public EditableElementInit(ElementInit elmInit)
: this()
{
AddMethod = elmInit.AddMethod;
foreach (Expression ex in elmInit.Arguments)
{
Arguments.Add(EditableExpression.Create(ex));
}
}
示例5: GetInitializers
private ElementInit[] GetInitializers(MethodInfo invoke, out ParameterExpression[] parameters)
{
ParameterInfo[] parameterInfos = invoke.GetParameters();
var initializers = new ElementInit[parameterInfos.Length];
parameters = new ParameterExpression[parameterInfos.Length];
for (var i = 0; i < parameterInfos.Length; i++)
{
Expression dictionaryValue;
Expression dictionaryKey;
ParameterExpression parameter;
BuildInitializer(out dictionaryValue, out dictionaryKey, out parameter, parameterInfos[i]);
parameters[i] = parameter;
initializers[i] = Expression.ElementInit(Tokens.DictionaryAdd, new[] { dictionaryKey, dictionaryValue });
}
return initializers;
}
示例6: VisitElementInit
/// <summary>
/// Visits an ElementInit node.
/// </summary>
/// <param name="node">The ElementInit node.</param>
/// <returns>The ElementInit node.</returns>
protected override ElementInit VisitElementInit(ElementInit node)
{
throw new NotImplementedException();
}
示例7: VisitElementInit
private static ElementInit VisitElementInit(ElementInit node)
{
throw new NotImplementedException();
}
示例8: VisitElementInitializer
protected virtual ElementInit VisitElementInitializer (ElementInit initializer)
{
Expression[] args;
if (VisitExpressionList (initializer.Arguments, out args))
return Expression.ElementInit (initializer.AddMethod, args);
return initializer;
}
示例9: VisitElementInitializer
/// <summary>
/// ElementInit visit method
/// </summary>
/// <param name="initializer">The ElementInit expression to visit</param>
/// <returns>The visited ElementInit expression </returns>
internal override ElementInit VisitElementInitializer(ElementInit initializer)
{
this.VisitExpressionList(initializer.Arguments);
return initializer;
}
示例10: ListInit
/// <summary>
/// Creates a <see cref="ListInitExpression"/> that uses a specified method to add elements to a collection.
/// </summary>
/// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param>
/// <param name="addMethod">A <see cref="MethodInfo"/> that represents an instance method named "Add" (case insensitive), that adds an element to a collection. </param>
/// <param name="initializers">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the Initializers collection.</param>
/// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns>
public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, IEnumerable<Expression> initializers)
{
if (addMethod == null)
{
return ListInit(newExpression, initializers);
}
ContractUtils.RequiresNotNull(newExpression, "newExpression");
ContractUtils.RequiresNotNull(initializers, "initializers");
var initializerlist = initializers.ToReadOnly();
if (initializerlist.Count == 0)
{
throw Error.ListInitializerWithZeroMembers();
}
ElementInit[] initList = new ElementInit[initializerlist.Count];
for (int i = 0; i < initializerlist.Count; i++)
{
initList[i] = ElementInit(addMethod, initializerlist[i]);
}
return ListInit(newExpression, new TrueReadOnlyCollection<ElementInit>(initList));
}
示例11: ElementInitNode
public ElementInitNode(INodeFactory factory, ElementInit elementInit)
: base(factory)
{
this.Initialize(elementInit);
}
示例12: SerializableElementInit
/// <summary>
/// Constructor with an <see cref="ElementInit"/> and an <see cref="ExpressionConverter"/>.
/// </summary>
/// <param name="elementInit">The original, not serializable <see cref="ElementInit"/>.</param>
/// <param name="expConverter">The <see cref="ExpressionConverter"/> to convert contained <see cref="Expression">Expressions</see>.</param>
public SerializableElementInit(ElementInit elementInit, ExpressionConverter expConverter)
{
Arguments = elementInit.Arguments.MakeSerializableCollection<SerializableExpression>(expConverter);
AddMethod = elementInit.AddMethod;
}
示例13: VisitElementInitializer
/// <summary>
/// ElementInit visit method
/// </summary>
/// <param name="initializer">The ElementInit expression to visit</param>
/// <returns>The visited ElementInit expression </returns>
internal override ElementInit VisitElementInitializer(ElementInit initializer)
{
throw new NotImplementedException();
}
示例14: VisitElementInitializer
protected virtual void VisitElementInitializer(ElementInit initializer)
{
this.VisitExpressionList(initializer.Arguments);
throw new NotImplementedException ();
}
示例15: PVisitElementInitializer
protected virtual void PVisitElementInitializer(ElementInit initializer)
{
}