Struct ValueFunc<T, TResult>
Represents a pointer to the method with single parameter and return type.
Implements
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public struct ValueFunc<T, TResult> : IValueDelegate<Func<T, TResult>>, ICallable<Func<T, TResult>>, IConvertible<Func<T, TResult>>, ISupplier<Func<T, TResult>>, IValueDelegate<Converter<T, TResult>>, ICallable<Converter<T, TResult>>, ICallable, IConvertible<Converter<T, TResult>>, ISupplier<Converter<T, TResult>>, IEquatable<ValueFunc<T, TResult>>
Type Parameters
Name | Description |
---|---|
T | The type of the first method parameter. |
TResult | The type of the return value of the method that this pointer encapsulates. |
Remarks
This method pointer is intended to call managed methods only.
Constructors
| Improve this Doc View SourceValueFunc(Func<T, TResult>, Boolean)
Initializes a new pointer based on extracted pointer from the delegate.
Declaration
public ValueFunc(Func<T, TResult> func, bool wrap = false)
Parameters
Type | Name | Description |
---|---|---|
Func<T, TResult> | func | The delegate representing method. |
Boolean | wrap | true to wrap |
Remarks
You can use this constructor to create value delegate once and cache it using static readonly
field
for subsequent calls.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ValueFunc(MethodInfo)
Initializes a new pointer to the method.
Declaration
public ValueFunc(MethodInfo method)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | method | The method to convert into pointer. |
Remarks
This constructor causes heap allocations because Reflection is needed to check compatibility of method's signature with the delegate type.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException | Signature of |
Properties
| Improve this Doc View SourceIsEmpty
Indicates that this delegate doesn't refer to any method.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Target
Gets the object on which the current pointer invokes the method.
Declaration
public object Target { get; }
Property Value
Type | Description |
---|---|
Object |
Methods
| Improve this Doc View SourceEquals(ValueFunc<T, TResult>)
Determines whether this object points to the same method as other object.
Declaration
public bool Equals(ValueFunc<T, TResult> other)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<T, TResult> | other | The pointer to compare. |
Returns
Type | Description |
---|---|
Boolean | true if both pointers represent the same method; otherwise, false. |
Equals(Object)
Determines whether this object points to the same method as other object.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | The object implementing ICallable<TDelegate> to compare. |
Returns
Type | Description |
---|---|
Boolean | true if both pointers represent the same method; otherwise, false. |
Overrides
| Improve this Doc View SourceGetHashCode()
Computes hash code of this pointer.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of this pointer. |
Overrides
| Improve this Doc View SourceInvoke(T)
Invokes method by pointer.
Declaration
public TResult Invoke(T arg)
Parameters
Type | Name | Description |
---|---|---|
T | arg | The first argument to be passed into the target method. |
Returns
Type | Description |
---|---|
TResult | The result of method invocation. |
ToDelegate()
Converts this pointer into Func<T,TResult>.
Declaration
public Func<T, TResult> ToDelegate()
Returns
Type | Description |
---|---|
Func<T, TResult> | The delegate created from this method pointer; or null if this pointer is zero. |
ToString()
Obtains pointer value in HEX format.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The address represented by pointer. |
Overrides
Operators
| Improve this Doc View SourceEquality(ValueFunc<T, TResult>, ValueFunc<T, TResult>)
Determines whether the pointers represent the same method.
Declaration
public static bool operator ==(in ValueFunc<T, TResult> first, in ValueFunc<T, TResult> second)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<T, TResult> | first | The first pointer to compare. |
ValueFunc<T, TResult> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
Boolean | true if both pointers represent the same method; otherwise, false. |
Explicit(ValueFunc<T, TResult> to Converter<T, TResult>)
Converts this pointer into Converter<TInput,TOutput>.
Declaration
public static explicit operator Converter<T, TResult>(in ValueFunc<T, TResult> func)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<T, TResult> | func | The pointer to convert. |
Returns
Type | Description |
---|---|
Converter<T, TResult> | The delegate created from this method pointer. |
Explicit(ValueFunc<T, TResult> to Func<T, TResult>)
Converts this pointer into Func<T,TResult>.
Declaration
public static explicit operator Func<T, TResult>(in ValueFunc<T, TResult> func)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<T, TResult> | func | The pointer to convert. |
Returns
Type | Description |
---|---|
Func<T, TResult> | The delegate created from this method pointer. |
Inequality(ValueFunc<T, TResult>, ValueFunc<T, TResult>)
Determines whether the pointers represent different methods.
Declaration
public static bool operator !=(in ValueFunc<T, TResult> first, in ValueFunc<T, TResult> second)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<T, TResult> | first | The first pointer to compare. |
ValueFunc<T, TResult> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
Boolean | true if both pointers represent different methods; otherwise, false. |
Explicit Interface Implementations
| Improve this Doc View SourceICallable.DynamicInvoke(Object[])
Declaration
object ICallable.DynamicInvoke(params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Object[] | args |
Returns
Type | Description |
---|---|
Object |
ICallable<Converter<T, TResult>>.ToDelegate()
Declaration
Converter<T, TResult> ICallable<Converter<T, TResult>>.ToDelegate()
Returns
Type | Description |
---|---|
Converter<T, TResult> |