Исходный код вики Сценарии

Версия 2.3 от Alexandr Fokin на 2023/05/31 09:56

Скрыть последних авторов
Alexandr Fokin 1.4 1 |(% style="width:432px" %)Компиляция дерева в делегат|(% style="width:1061px" %){{code language="c#"}}Expression
Alexandr Fokin 1.2 2 .Lambda(expressionValiarble)
Alexandr Fokin 1.4 3 .Compile();{{/code}}
Alexandr Fokin 2.2 4 |(% style="width:432px" %)[[Простое копирование свойств одного класса в другой>>doc:Разработка.NET.C#.Рантайм и типы.Expression tree | Деревья выражений.Сценарии.Простое копирование свойств одного класса в другой.WebHome]]|(% style="width:1061px" %)
5 |(% style="width:432px" %)[[Маппинг на основе выражения доступа к свойству>>doc:.Маппинг на основе выражения доступа к свойству.WebHome]]|(% style="width:1061px" %)
Alexandr Fokin 1.4 6 |(% style="width:432px" %)Вызов делегата при построении EpressionTree|(% style="width:1061px" %)Expression Trees and Invoking a Delegate
7 [[https:~~/~~/stackoverflow.com/questions/2215712/expression-trees-and-invoking-a-delegate>>url:https://stackoverflow.com/questions/2215712/expression-trees-and-invoking-a-delegate]]
8 |(% style="width:432px" %)Объявлений локальной переменной в блоке (без передачи извне)|(% style="width:1061px" %)(((
9 переменная типа указана из области видимости, но не определена 
10 [[https:~~/~~/question-it.com/questions/717473/peremennaja-tipa-ukazana-iz-oblasti-vidimosti-no-ne-opredelena>>url:https://question-it.com/questions/717473/peremennaja-tipa-ukazana-iz-oblasti-vidimosti-no-ne-opredelena]]
11 )))
12 |(% style="width:432px" %) |(% style="width:1061px" %)(((
13 How do I set a field value in an C# Expression tree?
14 [[https:~~/~~/stackoverflow.com/questions/321650/how-do-i-set-a-field-value-in-an-c-sharp-expression-tree>>https://stackoverflow.com/questions/321650/how-do-i-set-a-field-value-in-an-c-sharp-expression-tree]]
Alexandr Fokin 1.2 15
Alexandr Fokin 1.5 16 How do you call a constructor via an expression tree on an existing object?
17 [[https:~~/~~/stackoverflow.com/questions/16363838/how-do-you-call-a-constructor-via-an-expression-tree-on-an-existing-object>>https://stackoverflow.com/questions/16363838/how-do-you-call-a-constructor-via-an-expression-tree-on-an-existing-object]]
18
19 How do I set a field value in an C# Expression tree?
20 [[https:~~/~~/stackoverflow.com/questions/321650/how-do-i-set-a-field-value-in-an-c-sharp-expression-tree>>https://stackoverflow.com/questions/321650/how-do-i-set-a-field-value-in-an-c-sharp-expression-tree]]
Alexandr Fokin 1.4 21 )))
Alexandr Fokin 2.3 22 |(% style="width:432px" %)Вызов конструктора|(% style="width:1061px" %){{code language="c#"}}var constructorInfo = t.GetConstructors().First(e => e.Attributes.HasFlag(MethodAttributes.Public));
23 var constructorParameter1 = Expression.Parameter(typeof(bool));
24 var constructorExp = Expression.New(constructorInfo, constructorParameter1);
Alexandr Fokin 1.2 25
Alexandr Fokin 2.3 26 // Func<bool, object> or Func<bool, T>
27 var constructorDelegate = Expression
28 .Lambda<Func<bool, object>>(
29 constructorExp,
30 deletedParameter
31 )
32 .Compile();{{/code}}
33
Alexandr Fokin 1.5 34 ==== ====
Alexandr Fokin 1.2 35
Alexandr Fokin 1.5 36 ==== ====
Alexandr Fokin 1.2 37
Alexandr Fokin 1.5 38 ==== ====
Alexandr Fokin 1.2 39
40
Alexandr Fokin 1.4 41 ----
Alexandr Fokin 1.2 42
Alexandr Fokin 1.5 43 ==== ====
Alexandr Fokin 1.2 44
45
46 ----
47
Alexandr Fokin 1.3 48
49 ----
50