Extracting static extension methods into separate file
This commit is contained in:
parent
9da952aa28
commit
57f2139dba
@ -0,0 +1,13 @@
|
|||||||
|
using TelegramBotBase.Base;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Actions
|
||||||
|
{
|
||||||
|
public static class EndsWithAction_Extensions
|
||||||
|
{
|
||||||
|
public static void AddEndsWithAction(this ExternalActionManager manager, string value, Func<String, UpdateResult, MessageResult, Task> action)
|
||||||
|
{
|
||||||
|
manager.Add(new EndsWithAction(value, action));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -26,12 +26,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Actions
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EndsWithAction_Extensions
|
|
||||||
{
|
|
||||||
public static void AddEndsWithAction(this ExternalActionManager manager, string value, Func<String, UpdateResult, MessageResult, Task> action)
|
|
||||||
{
|
|
||||||
manager.Add(new EndsWithAction(value, action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
using TelegramBotBase.Base;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Actions
|
||||||
|
{
|
||||||
|
public static class GuidAction_Extensions
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void AddGuidAction(this ExternalActionManager manager, string method, Func<Guid, UpdateResult, MessageResult, Task> action)
|
||||||
|
{
|
||||||
|
manager.Add(new GuidAction(method, action));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -82,13 +82,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Actions
|
|||||||
public static CallbackData GetCallback(string method, Guid guid) => new CallbackData(method, guid.ToString());
|
public static CallbackData GetCallback(string method, Guid guid) => new CallbackData(method, guid.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GuidAction_Extensions
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void AddGuidAction(this ExternalActionManager manager, string method, Func<Guid, UpdateResult, MessageResult, Task> action)
|
|
||||||
{
|
|
||||||
manager.Add(new GuidAction(method, action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
using TelegramBotBase.Base;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Actions
|
||||||
|
{
|
||||||
|
public static class StartWithAction_Extensions
|
||||||
|
{
|
||||||
|
public static void AddStartsWithAction(this ExternalActionManager manager, string value, Func<String, UpdateResult, MessageResult, Task> action)
|
||||||
|
{
|
||||||
|
manager.Add(new StartWithAction(value, action));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -26,12 +26,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Actions
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StartWithAction_Extensions
|
|
||||||
{
|
|
||||||
public static void AddStartsWithAction(this ExternalActionManager manager, string value, Func<String, UpdateResult, MessageResult, Task> action)
|
|
||||||
{
|
|
||||||
manager.Add(new StartWithAction(value, action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,63 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
|
{
|
||||||
|
public static class EndsWithNavigation_Extensions
|
||||||
|
{
|
||||||
|
public static void AddEndsWithNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, string>> propertySelector)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<TForm, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new EndsWithNavigation<TForm>(method, setter));
|
||||||
|
}
|
||||||
|
public static void AddEndsWithNavigation<TForm>(this ExternalActionManager manager, string value, Action<TForm, string> setProperty)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new EndsWithNavigation<TForm>(value, setProperty));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddEndsWithNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, string>> propertySelector)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<FormBase, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new EndsWithNavigation(formType, value, setter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddEndsWithNavigation(this ExternalActionManager manager, Type formType, string value, Action<FormBase, string> setProperty)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new EndsWithNavigation(formType, value, setProperty));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Linq.Expressions;
|
using TelegramBotBase.Base;
|
||||||
using TelegramBotBase.Base;
|
|
||||||
using TelegramBotBase.Form;
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
@ -75,61 +74,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EndsWithNavigation_Extensions
|
|
||||||
{
|
|
||||||
public static void AddEndsWithNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, string>> propertySelector)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<TForm, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new EndsWithNavigation<TForm>(method, setter));
|
|
||||||
}
|
|
||||||
public static void AddEndsWithNavigation<TForm>(this ExternalActionManager manager, string value, Action<TForm, string> setProperty)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new EndsWithNavigation<TForm>(value, setProperty));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddEndsWithNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, string>> propertySelector)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<FormBase, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new EndsWithNavigation(formType, value, setter));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddEndsWithNavigation(this ExternalActionManager manager, Type formType, string value, Action<FormBase, string> setProperty)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new EndsWithNavigation(formType, value, setProperty));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,63 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
|
{
|
||||||
|
public static class GuidNavigation_Extensions
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void AddGuidNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, Guid>> propertySelector)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<TForm, Guid>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new GuidNavigation<TForm>(method, setter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGuidNavigation<TForm>(this ExternalActionManager manager, string method, Action<TForm, Guid> action)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new GuidNavigation<TForm>(method, action));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGuidNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, Guid>> propertySelector)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<FormBase, Guid>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new GuidNavigation(formType, value, setter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGuidNavigation(this ExternalActionManager manager, Type formType, string method, Action<FormBase, Guid> action)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new GuidNavigation(formType, method, action));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Linq.Expressions;
|
using TelegramBotBase.Base;
|
||||||
using TelegramBotBase.Base;
|
|
||||||
using TelegramBotBase.Form;
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
@ -107,62 +106,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
|||||||
|
|
||||||
public static CallbackData GetCallback(string method, Guid guid) => new CallbackData(method, guid.ToString());
|
public static CallbackData GetCallback(string method, Guid guid) => new CallbackData(method, guid.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GuidNavigation_Extensions
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void AddGuidNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, Guid>> propertySelector)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<TForm, Guid>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new GuidNavigation<TForm>(method, setter));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddGuidNavigation<TForm>(this ExternalActionManager manager, string method, Action<TForm, Guid> action)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new GuidNavigation<TForm>(method, action));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddGuidNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, Guid>> propertySelector)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<FormBase, Guid>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new GuidNavigation(formType, value, setter));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddGuidNavigation(this ExternalActionManager manager, Type formType, string method, Action<FormBase, Guid> action)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new GuidNavigation(formType, method, action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,63 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
|
{
|
||||||
|
public static class StartWithNavigation_Extensions
|
||||||
|
{
|
||||||
|
public static void AddStartsWithNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, string>> propertySelector)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<TForm, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new StartWithNavigation<TForm>(method, setter));
|
||||||
|
}
|
||||||
|
public static void AddStartsWithNavigation<TForm>(this ExternalActionManager manager, string value, Action<TForm, string> setProperty)
|
||||||
|
where TForm : FormBase
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new StartWithNavigation<TForm>(value, setProperty));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddStartsWithNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, string>> propertySelector)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
||||||
|
|
||||||
|
var assign = Expression.Lambda<Action<FormBase, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
||||||
|
|
||||||
|
var setter = assign.Compile(true);
|
||||||
|
|
||||||
|
manager.Add(new StartWithNavigation(formType, value, setter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddStartsWithNavigation(this ExternalActionManager manager, Type formType, string value, Action<FormBase, string> setProperty)
|
||||||
|
{
|
||||||
|
if (!typeof(FormBase).IsAssignableFrom(formType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.Add(new StartWithNavigation(formType, value, setProperty));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Linq.Expressions;
|
using TelegramBotBase.Base;
|
||||||
using TelegramBotBase.Base;
|
|
||||||
using TelegramBotBase.Form;
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
||||||
@ -72,61 +71,4 @@ namespace TelegramBotBase.Experiments.ActionManager.Navigation
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StartWithNavigation_Extensions
|
|
||||||
{
|
|
||||||
public static void AddStartsWithNavigation<TForm>(this ExternalActionManager manager, string method, Expression<Func<TForm, string>> propertySelector)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<TForm, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new StartWithNavigation<TForm>(method, setter));
|
|
||||||
}
|
|
||||||
public static void AddStartsWithNavigation<TForm>(this ExternalActionManager manager, string value, Action<TForm, string> setProperty)
|
|
||||||
where TForm : FormBase
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(typeof(TForm)))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(TForm)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new StartWithNavigation<TForm>(value, setProperty));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddStartsWithNavigation(this ExternalActionManager manager, Type formType, string value, Expression<Func<FormBase, string>> propertySelector)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
var newValue = Expression.Parameter(propertySelector.Body.Type);
|
|
||||||
|
|
||||||
var assign = Expression.Lambda<Action<FormBase, string>>(Expression.Assign(propertySelector.Body, newValue), propertySelector.Parameters[0], newValue);
|
|
||||||
|
|
||||||
var setter = assign.Compile(true);
|
|
||||||
|
|
||||||
manager.Add(new StartWithNavigation(formType, value, setter));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddStartsWithNavigation(this ExternalActionManager manager, Type formType, string value, Action<FormBase, string> setProperty)
|
|
||||||
{
|
|
||||||
if (!typeof(FormBase).IsAssignableFrom(formType))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"{nameof(formType)} argument must be a {nameof(FormBase)} type");
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.Add(new StartWithNavigation(formType, value, setProperty));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user