mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 01:11:52 +08:00
1fa3652d26
* feat(module: slider): implement two-way binding * feat(module: slider): remove mouseup handler * feat(module: slider): inherits from AntInputComponentBase * fix(module: slider): onclick will be fired with onmouseup * feat(module: slider): move convert method to public extensions * feat(module: slider): update to fit form component * fix(module: slider): two-way binding does not notify value change * feat(module: slider): update input demo with two-way binding * feat(module: slider): remove OnProertyChanged
30 lines
946 B
C#
30 lines
946 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AntDesign.core.Extensions
|
|
{
|
|
public static class DataConvertionExtensions
|
|
{
|
|
public static TTo Convert<TFrom, TTo>(TFrom fromValue)
|
|
{
|
|
// Creating a parameter expression
|
|
ParameterExpression fromExpression = Expression.Parameter(typeof(TFrom), "from");
|
|
|
|
// Creating a parameter express
|
|
ParameterExpression toExpression = Expression.Parameter(typeof(TTo), "to");
|
|
|
|
// Creating a method body
|
|
BlockExpression blockExpression = Expression.Block(
|
|
new[] { toExpression },
|
|
Expression.Assign(toExpression, fromExpression)
|
|
);
|
|
|
|
return Expression.Lambda<Func<TFrom, TTo>>(blockExpression, fromExpression).Compile()(fromValue);
|
|
}
|
|
}
|
|
}
|