parent
a296e9ad74
commit
c41d40c56b
|
|
@ -419,6 +419,8 @@ namespace Microsoft.AspNetCore.Components
|
||||||
}
|
}
|
||||||
public static partial class RuntimeHelpers
|
public static partial class RuntimeHelpers
|
||||||
{
|
{
|
||||||
|
public static Microsoft.AspNetCore.Components.EventCallback<T> CreateInferredEventCallback<T>(object receiver, System.Action<T> callback, T value) { throw null; }
|
||||||
|
public static Microsoft.AspNetCore.Components.EventCallback<T> CreateInferredEventCallback<T>(object receiver, System.Func<T, System.Threading.Tasks.Task> callback, T value) { throw null; }
|
||||||
public static T TypeCheck<T>(T value) { throw null; }
|
public static T TypeCheck<T>(T value) { throw null; }
|
||||||
}
|
}
|
||||||
public partial class UIChangeEventArgs : Microsoft.AspNetCore.Components.UIEventArgs
|
public partial class UIChangeEventArgs : Microsoft.AspNetCore.Components.UIEventArgs
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Components
|
namespace Microsoft.AspNetCore.Components
|
||||||
{
|
{
|
||||||
|
|
@ -17,6 +18,43 @@ namespace Microsoft.AspNetCore.Components
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
//
|
||||||
|
// This method is used to create an expression binding site with a compile-time known type. This helps with providing
|
||||||
|
// good error messages, as well as proper method-group-to-delegate conversion when assigning component parameters.
|
||||||
public static T TypeCheck<T>(T value) => value;
|
public static T TypeCheck<T>(T value) => value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Not intended for use by application code.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="receiver"></param>
|
||||||
|
/// <param name="callback"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//
|
||||||
|
// This method is used with `@bind-Value` for components. When a component has a generic type, it's
|
||||||
|
// really messy to write to try and write the parameter type for ValueChanged - because it can contain generic
|
||||||
|
// type parameters. We're using a trick of type inference to generate the proper typing for the delegate
|
||||||
|
// so that method-group-to-delegate conversion works.
|
||||||
|
public static EventCallback<T> CreateInferredEventCallback<T>(object receiver, Action<T> callback, T value)
|
||||||
|
{
|
||||||
|
return EventCallback.Factory.Create<T>(receiver, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Not intended for use by application code.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="receiver"></param>
|
||||||
|
/// <param name="callback"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//
|
||||||
|
// This method is used with `@bind-Value` for components. When a component has a generic type, it's
|
||||||
|
// really messy to write to try and write the parameter type for ValueChanged - because it can contain generic
|
||||||
|
// type parameters. We're using a trick of type inference to generate the proper typing for the delegate
|
||||||
|
// so that method-group-to-delegate conversion works.
|
||||||
|
public static EventCallback<T> CreateInferredEventCallback<T>(object receiver, Func<T, Task> callback, T value)
|
||||||
|
{
|
||||||
|
return EventCallback.Factory.Create<T>(receiver, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue