diff --git a/TelegramBotBase/Interfaces/IStateMachine.cs b/TelegramBotBase/Interfaces/IStateMachine.cs index 7ba2c7c..7cd3e65 100644 --- a/TelegramBotBase/Interfaces/IStateMachine.cs +++ b/TelegramBotBase/Interfaces/IStateMachine.cs @@ -9,7 +9,7 @@ namespace TelegramBotBase.Interfaces { public interface IStateMachine { - Type DefaultStateForm { get; } + Type FallbackStateForm { get; } void SaveFormStates(SaveStatesEventArgs e); diff --git a/TelegramBotBase/SessionBase.cs b/TelegramBotBase/SessionBase.cs index 8859cb0..5a66133 100644 --- a/TelegramBotBase/SessionBase.cs +++ b/TelegramBotBase/SessionBase.cs @@ -222,14 +222,15 @@ namespace TelegramBotBase //Skip classes where IgnoreState attribute is existing if (form.GetType().GetCustomAttributes(typeof(IgnoreState), true).Length != 0) { - if (statemachine.DefaultStateForm == null) + //Skip this form, when there is no fallback state form + if (statemachine.FallbackStateForm == null) { continue; } //Replace form by default State one. - se.FormUri = statemachine.DefaultStateForm.FullName; - se.QualifiedName = statemachine.DefaultStateForm.AssemblyQualifiedName; + se.FormUri = statemachine.FallbackStateForm.FullName; + se.QualifiedName = statemachine.FallbackStateForm.AssemblyQualifiedName; } //Is Subclass of IStateForm diff --git a/TelegramBotBase/States/JSONStateMachine.cs b/TelegramBotBase/States/JSONStateMachine.cs index 1e46f36..d8995be 100644 --- a/TelegramBotBase/States/JSONStateMachine.cs +++ b/TelegramBotBase/States/JSONStateMachine.cs @@ -19,26 +19,26 @@ namespace TelegramBotBase.States public bool Overwrite { get; set; } - public Type DefaultStateForm { get; private set; } + public Type FallbackStateForm { get; private set; } /// /// Will initialize the state machine. /// /// Path of the file and name where to save the session details. - /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . + /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . /// Declares of the file could be overwritten. - public JSONStateMachine(String file, Type defaultStateForm = null, bool overwrite = true) + public JSONStateMachine(String file, Type fallbackStateForm = null, bool overwrite = true) { if (file is null) { throw new ArgumentNullException(nameof(file)); } - this.DefaultStateForm = defaultStateForm ?? typeof(FormBase); + this.FallbackStateForm = fallbackStateForm; - if (!this.DefaultStateForm.IsSubclassOf(typeof(FormBase))) + if (!this.FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("DefaultStateForm is not a subclass of FormBase"); + throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); } this.FilePath = file; diff --git a/TelegramBotBase/States/SimpleJSONStateMachine.cs b/TelegramBotBase/States/SimpleJSONStateMachine.cs index d895d20..0b6e9e5 100644 --- a/TelegramBotBase/States/SimpleJSONStateMachine.cs +++ b/TelegramBotBase/States/SimpleJSONStateMachine.cs @@ -19,26 +19,26 @@ namespace TelegramBotBase.States public bool Overwrite { get; set; } - public Type DefaultStateForm { get; private set; } + public Type FallbackStateForm { get; private set; } /// /// Will initialize the state machine. /// /// Path of the file and name where to save the session details. - /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . + /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . /// Declares of the file could be overwritten. - public SimpleJSONStateMachine(String file, Type defaultStateForm = null, bool overwrite = true) + public SimpleJSONStateMachine(String file, Type fallbackStateForm = null, bool overwrite = true) { if (file is null) { throw new ArgumentNullException(nameof(file)); } - this.DefaultStateForm = defaultStateForm ?? typeof(FormBase); + this.FallbackStateForm = fallbackStateForm; - if (!this.DefaultStateForm.IsSubclassOf(typeof(FormBase))) + if (!this.FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("DefaultStateForm is not a subclass of FormBase"); + throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); } this.FilePath = file; diff --git a/TelegramBotBase/States/XMLStateMachine.cs b/TelegramBotBase/States/XMLStateMachine.cs index ab5ca7a..76fe5bd 100644 --- a/TelegramBotBase/States/XMLStateMachine.cs +++ b/TelegramBotBase/States/XMLStateMachine.cs @@ -18,26 +18,26 @@ namespace TelegramBotBase.States public bool Overwrite { get; set; } - public Type DefaultStateForm { get; private set; } + public Type FallbackStateForm { get; private set; } /// /// Will initialize the state machine. /// /// Path of the file and name where to save the session details. - /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . + /// Type of Form which will be saved instead of Form which has attribute declared. Needs to be subclass of . /// Declares of the file could be overwritten. - public XMLStateMachine(String file, Type defaultStateForm = null, bool overwrite = true) + public XMLStateMachine(String file, Type fallbackStateForm = null, bool overwrite = true) { if (file is null) { throw new ArgumentNullException(nameof(file)); } - this.DefaultStateForm = defaultStateForm ?? typeof(FormBase); + this.FallbackStateForm = fallbackStateForm; - if (!this.DefaultStateForm.IsSubclassOf(typeof(FormBase))) + if (!this.FallbackStateForm.IsSubclassOf(typeof(FormBase))) { - throw new ArgumentException("DefaultStateForm is not a subclass of FormBase"); + throw new ArgumentException("FallbackStateForm is not a subclass of FormBase"); } this.FilePath = file;