Expression.New メソッド

定義

NewExpressionを作成します。

オーバーロード

名前 説明
New(ConstructorInfo)

引数を受け取っていない指定したコンストラクターの呼び出しを表す NewExpression を作成します。

New(Type)

指定した型のパラメーターなしのコンストラクターの呼び出しを表す NewExpression を作成します。

New(ConstructorInfo, IEnumerable<Expression>)

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。

New(ConstructorInfo, Expression[])

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。

New(ConstructorInfo, IEnumerable<Expression>, IEnumerable<MemberInfo>)

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。 コンストラクターの初期化されたフィールドにアクセスするメンバーが指定されます。

New(ConstructorInfo, IEnumerable<Expression>, MemberInfo[])

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。 コンストラクターの初期化されたフィールドにアクセスするメンバーは、配列として指定されます。

New(ConstructorInfo)

引数を受け取っていない指定したコンストラクターの呼び出しを表す NewExpression を作成します。

public:
 static System::Linq::Expressions::NewExpression ^ New(System::Reflection::ConstructorInfo ^ constructor);
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor);
static member New : System.Reflection.ConstructorInfo -> System.Linq.Expressions.NewExpression
Public Shared Function New (constructor As ConstructorInfo) As NewExpression

パラメーター

constructor
ConstructorInfo

ConstructorInfo プロパティを等しく設定するConstructor

返品

NewExpression プロパティが NodeType と等しく、New プロパティが指定した値に設定されているConstructor

例外

constructornullです。

constructorが表すコンストラクターには、少なくとも 1 つのパラメーターがあります。

注釈

結果のArgumentsMembersプロパティとNewExpressionプロパティは空のコレクションです。 Type プロパティは、constructorで表されるコンストラクターの宣言型を表します。

適用対象

New(Type)

指定した型のパラメーターなしのコンストラクターの呼び出しを表す NewExpression を作成します。

public:
 static System::Linq::Expressions::NewExpression ^ New(Type ^ type);
public static System.Linq.Expressions.NewExpression New(Type type);
static member New : Type -> System.Linq.Expressions.NewExpression
Public Shared Function New (type As Type) As NewExpression

パラメーター

type
Type

引数を受け取たないコンストラクターを持つ Type

返品

NewExpression プロパティが NodeType と等しく、New プロパティが、指定した型のパラメーターを持たないコンストラクターを表すConstructorに設定されているConstructorInfo

例外

typenullです。

type表す型には、パラメーターのないコンストラクターがありません。

次の例では、 New(Type) メソッドを使用して、パラメーターなしでコンストラクターを呼び出してディクショナリ オブジェクトの新しいインスタンスを構築することを表す NewExpression を作成する方法を示します。

// Create a NewExpression that represents constructing
// a new instance of Dictionary<int, string>.
System.Linq.Expressions.NewExpression newDictionaryExpression =
    System.Linq.Expressions.Expression.New(typeof(Dictionary<int, string>));

Console.WriteLine(newDictionaryExpression.ToString());

// This code produces the following output:
//
// new Dictionary`2()
' Create a NewExpression that represents constructing
' a new instance of Dictionary(Of Integer, String).
Dim newDictionaryExpression As System.Linq.Expressions.NewExpression = _
    System.Linq.Expressions.Expression.[New]( _
        Type.GetType("System.Collections.Generic.Dictionary`2[System.Int32, System.String]"))

Console.WriteLine(newDictionaryExpression.ToString())

' This code produces the following output:
'
' new Dictionary`2()

注釈

type パラメーターは、パラメーターのないコンストラクターを持つ型を表す必要があります。

結果のArgumentsMembersプロパティとNewExpressionプロパティは空のコレクションです。 Type プロパティは、typeと同じです。

適用対象

New(ConstructorInfo, IEnumerable<Expression>)

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。

public:
 static System::Linq::Expressions::NewExpression ^ New(System::Reflection::ConstructorInfo ^ constructor, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments);
static member New : System.Reflection.ConstructorInfo * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.NewExpression
Public Shared Function New (constructor As ConstructorInfo, arguments As IEnumerable(Of Expression)) As NewExpression

パラメーター

constructor
ConstructorInfo

ConstructorInfo プロパティを等しく設定するConstructor

arguments
IEnumerable<Expression>

IEnumerable<T> コレクションの設定に使用するExpression オブジェクトを含むArguments

返品

NewExpression プロパティが NodeType と等しく、NewプロパティとConstructorプロパティが指定した値に設定されているArguments

例外

constructornullです。

-または-

argumentsの要素がnull

arguments パラメーターには、constructorが表すコンストラクターのパラメーターの数と同じ数の要素が含まれていません。

-または-

Typeの要素のargumentsプロパティは、constructorが表すコンストラクターの対応するパラメーターの型には割り当てできません。

注釈

arguments パラメーターには、constructorで表されるコンストラクターのパラメーターの数と同じ数の要素が含まれている必要があります。 argumentsnullされている場合は空と見なされ、結果のArgumentsNewExpression プロパティは空のコレクションになります。

結果のTypeNewExpression プロパティは、constructorによって表されるコンストラクターの宣言型を表します。 Members プロパティは空のコレクションです。

適用対象

New(ConstructorInfo, Expression[])

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。

public:
 static System::Linq::Expressions::NewExpression ^ New(System::Reflection::ConstructorInfo ^ constructor, ... cli::array <System::Linq::Expressions::Expression ^> ^ arguments);
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, params System.Linq.Expressions.Expression[] arguments);
static member New : System.Reflection.ConstructorInfo * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.NewExpression
Public Shared Function New (constructor As ConstructorInfo, ParamArray arguments As Expression()) As NewExpression

パラメーター

constructor
ConstructorInfo

ConstructorInfo プロパティを等しく設定するConstructor

arguments
Expression[]

Expression コレクションの設定に使用するArguments オブジェクトの配列。

返品

NewExpression プロパティが NodeType と等しく、NewプロパティとConstructorプロパティが指定した値に設定されているArguments

例外

constructornullです。

-または-

argumentsの要素がnull

argumentsの長さは、constructorが表すコンストラクターのパラメーターの数と一致します。

-または-

Typeの要素のargumentsプロパティは、constructorが表すコンストラクターの対応するパラメーターの型には割り当てできません。

注釈

arguments パラメーターには、constructorで表されるコンストラクターのパラメーターの数と同じ数の要素が含まれている必要があります。 argumentsnullされている場合は空と見なされ、結果のArgumentsNewExpression プロパティは空のコレクションになります。

結果のTypeNewExpression プロパティは、constructorによって表されるコンストラクターの宣言型を表します。 Members プロパティは空のコレクションです。

適用対象

New(ConstructorInfo, IEnumerable<Expression>, IEnumerable<MemberInfo>)

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。 コンストラクターの初期化されたフィールドにアクセスするメンバーが指定されます。

public:
 static System::Linq::Expressions::NewExpression ^ New(System::Reflection::ConstructorInfo ^ constructor, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments, System::Collections::Generic::IEnumerable<System::Reflection::MemberInfo ^> ^ members);
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments, System.Collections.Generic.IEnumerable<System.Reflection.MemberInfo> members);
static member New : System.Reflection.ConstructorInfo * seq<System.Linq.Expressions.Expression> * seq<System.Reflection.MemberInfo> -> System.Linq.Expressions.NewExpression
Public Shared Function New (constructor As ConstructorInfo, arguments As IEnumerable(Of Expression), members As IEnumerable(Of MemberInfo)) As NewExpression

パラメーター

constructor
ConstructorInfo

ConstructorInfo プロパティを等しく設定するConstructor

arguments
IEnumerable<Expression>

IEnumerable<T> コレクションの設定に使用するExpression オブジェクトを含むArguments

members
IEnumerable<MemberInfo>

IEnumerable<T> コレクションの設定に使用するMemberInfo オブジェクトを含むMembers

返品

NewExpression プロパティが NodeType と等しく、NewConstructor、およびArgumentsプロパティが指定した値に設定されているMembers

例外

constructornullです。

-または-

argumentsの要素がnull

-または-

membersの要素がnull

arguments パラメーターには、constructorが表すコンストラクターのパラメーターの数と同じ数の要素が含まれていません。

-または-

Typeの要素のargumentsプロパティは、constructorが表すコンストラクターの対応するパラメーターの型には割り当てできません。

-または-

members パラメーターには、argumentsと同じ数の要素がありません。

-または-

argumentsの要素には、Typeの対応する要素によって表されるメンバーの型に割り当てられない型を表すmembers プロパティがあります。

注釈

arguments パラメーターには、constructorで表されるコンストラクターのパラメーターの数と同じ数の要素が含まれている必要があります。 argumentsnullされている場合は空と見なされ、結果のArgumentsNewExpression プロパティは空のコレクションになります。

membersnull場合、結果のMembersNewExpression プロパティは空のコレクションになります。 membersnullされていない場合は、argumentsと同じ数の要素を持つ必要があり、各要素をnullすることはできません。 membersの各要素は、PropertyInfoによって表されるコンストラクターの宣言型のインスタンス メンバーを表すFieldInfoMethodInfo、またはconstructorである必要があります。 プロパティを表す場合、プロパティには get アクセサーが必要です。 argumentsの各要素のmembersの対応する要素には、Type要素が表すメンバーの型に割り当て可能な型を表すmembers プロパティが必要です。

結果のTypeNewExpression プロパティは、constructorが表すコンストラクターの宣言型を表します。

適用対象

New(ConstructorInfo, IEnumerable<Expression>, MemberInfo[])

指定した引数を持つ指定したコンストラクターの呼び出しを表す NewExpression を作成します。 コンストラクターの初期化されたフィールドにアクセスするメンバーは、配列として指定されます。

public:
 static System::Linq::Expressions::NewExpression ^ New(System::Reflection::ConstructorInfo ^ constructor, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ arguments, ... cli::array <System::Reflection::MemberInfo ^> ^ members);
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> arguments, params System.Reflection.MemberInfo[] members);
static member New : System.Reflection.ConstructorInfo * seq<System.Linq.Expressions.Expression> * System.Reflection.MemberInfo[] -> System.Linq.Expressions.NewExpression
Public Shared Function New (constructor As ConstructorInfo, arguments As IEnumerable(Of Expression), ParamArray members As MemberInfo()) As NewExpression

パラメーター

constructor
ConstructorInfo

ConstructorInfo プロパティを等しく設定するConstructor

arguments
IEnumerable<Expression>

IEnumerable<T> コレクションの設定に使用するExpression オブジェクトを含むArguments

members
MemberInfo[]

MemberInfo コレクションの設定に使用するMembers オブジェクトの配列。

返品

NewExpression プロパティが NodeType と等しく、NewConstructor、およびArgumentsプロパティが指定した値に設定されているMembers

例外

constructornullです。

-または-

argumentsの要素がnull

-または-

membersの要素がnull

arguments パラメーターには、constructorが表すコンストラクターのパラメーターの数と同じ数の要素が含まれていません。

-または-

Typeの要素のargumentsプロパティは、constructorが表すコンストラクターの対応するパラメーターの型には割り当てできません。

-または-

members パラメーターには、argumentsと同じ数の要素がありません。

-または-

argumentsの要素には、Typeの対応する要素によって表されるメンバーの型に割り当てられない型を表すmembers プロパティがあります。

注釈

arguments パラメーターには、constructorで表されるコンストラクターのパラメーターの数と同じ数の要素が含まれている必要があります。 argumentsnullされている場合は空と見なされ、結果のArgumentsNewExpression プロパティは空のコレクションになります。

membersnull場合、結果のMembersNewExpression プロパティは空のコレクションになります。 membersnullされていない場合は、argumentsと同じ数の要素を持つ必要があり、各要素をnullすることはできません。 membersの各要素は、PropertyInfoによって表されるコンストラクターの宣言型のインスタンス メンバーを表すFieldInfoMethodInfo、またはconstructorである必要があります。 プロパティを表す場合、プロパティは関連付けられているフィールドの値を取得できる必要があります。 argumentsの各要素のmembersの対応する要素には、Type要素が表すメンバーの型に割り当て可能な型を表すmembers プロパティが必要です。

結果のTypeNewExpression プロパティは、constructorが表すコンストラクターの宣言型を表します。

適用対象