Update SessionBase.cs

- improving handling for Sessions loading with no default constructors available.
This commit is contained in:
FlorianDahn 2020-09-15 16:42:40 +02:00
parent 31c8231b2d
commit 48b76a84be

View File

@ -130,7 +130,19 @@ namespace TelegramBotBase
continue;
}
var form = t.GetConstructor(new Type[] { }).Invoke(new object[] { }) as FormBase;
var form = t.GetConstructor(new Type[] { })?.Invoke(new object[] { }) as FormBase;
//No default constructor
if (form == null)
{
form = Activator.CreateInstance(t) as FormBase;
if (form == null)
{
continue;
}
}
if (s.Values != null && s.Values.Count > 0)
{