11 [global::__DynamicallyInvokable]
14 private sealed
class LambdaSignature<
T> where
T : class
16 internal static readonly LambdaSignature<T>
Instance =
new LambdaSignature<T>();
22 private LambdaSignature()
24 Type typeFromHandle = typeof(
T);
27 throw Error.TypeParameterIsNotDelegate(typeFromHandle);
30 ParameterInfo[] parametersCached = method.GetParametersCached();
31 if (parametersCached[0].ParameterType != typeof(
CallSite))
33 throw Error.FirstArgumentMustBeCallSite();
36 for (
int i = 0; i < array.Length; i++)
38 array[i] =
Expression.Parameter(parametersCached[i + 1].ParameterType,
"$arg" + i);
40 Parameters =
new TrueReadOnlyCollection<ParameterExpression>(array);
41 ReturnLabel =
Expression.Label(method.GetReturnType());
51 [global::__DynamicallyInvokable]
54 [global::__DynamicallyInvokable]
62 [global::__DynamicallyInvokable]
72 [global::__DynamicallyInvokable]
80 [global::__DynamicallyInvokable]
86 internal T BindCore<T>(
CallSite<T> site,
object[] args) where
T :
class 88 T val = BindDelegate(site, args);
93 LambdaSignature<T> instance = LambdaSignature<T>.Instance;
94 Expression expression =
Bind(args, instance.Parameters, instance.ReturnLabel);
95 if (expression ==
null)
97 throw Error.NoOrInvalidRuleProduced();
101 throw Error.HomogenousAppDomainRequired();
104 T val2 = expression2.Compile();
112 [global::__DynamicallyInvokable]
115 GetRuleCache<T>().AddRule(target);
122 readOnlyCollectionBuilder.
Add(binding);
126 readOnlyCollectionBuilder.
Add(item);
128 return new Expression<T>(
Expression.Block(readOnlyCollectionBuilder),
"CallSite.Target", tailCall:
true,
new TrueReadOnlyCollection<ParameterExpression>(array));
131 internal RuleCache<T> GetRuleCache<T>() where T : class
143 value = (cache[typeof(T)] =
new RuleCache<T>());
146 return value as RuleCache<T>;
Discovers the attributes of a parameter and provides access to parameter metadata.
The builder for read only collection.
Discovers the attributes of a method and provides access to method metadata.
virtual T BindDelegate< T >(CallSite< T > site, object[] args)
Provides low-level runtime binding support. Classes can override this and provide a direct delegate f...
Represents a multicast delegate; that is, a delegate that can have more than one element in its invoc...
CallSiteBinder()
Initializes a new instance of the T:System.Runtime.CompilerServices.CallSiteBinder class.
A dynamic call site base class. This type is used as a parameter type to the dynamic site targets.
Used to represent the target of a T:System.Linq.Expressions.GotoExpression.
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
bool IsHomogenous
Gets a value that indicates whether the current application domain has a set of permissions that is g...
Represents an application domain, which is an isolated environment where applications execute....
virtual bool IsSubclassOf(Type c)
Determines whether the current T:System.Type derives from the specified T:System.Type.
static LabelTarget UpdateLabel
Gets a label that can be used to cause the binding to be updated. It indicates that the expression's ...
abstract Expression Bind(object[] args, ReadOnlyCollection< ParameterExpression > parameters, LabelTarget returnLabel)
Performs the runtime binding of the dynamic operation on a set of arguments.
Provides the base class from which the classes that represent expression tree nodes are derived....
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
Represents type declarations: class types, interface types, array types, value types,...
Creates and caches binding rules.
Represents a named parameter expression.
MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for the specified method whose parameters match the specified argument types and modifiers,...
void Add(T item)
Adds an item to the T:System.Runtime.CompilerServices.ReadOnlyCollectionBuilder`1.
Represents a collection of keys and values.To browse the .NET Framework source code for this type,...
Class responsible for runtime binding of the dynamic operations on the dynamic call site.
void CacheTarget< T >(T target)
Adds a target to the cache of known targets. The cached targets will be scanned before calling BindDe...
Specifies that instance members are to be included in the search.
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
Provides atomic operations for variables that are shared by multiple threads.