Ejemplo n.º 1
0
        public static T CastOptionTo <T>(ILibraryOptions options) where T : class, ILibraryOptions, new()
        {
            EnsureSameType <T>(options);
            var opt = (options ?? new T()) as T;

            return(opt);
        }
Ejemplo n.º 2
0
        public override void AddSuccessToastMessage(string message = null, ILibraryOptions toastrOptions = null)
        {
            var options      = OptionsHelpers.PrepareOptionsToastr(toastrOptions, NotificationTypesToastr.Success, _defaultNtoastNotifyOptions.DefaultSuccessTitle);
            var toastMessage = new ToastrMessage(message ?? _defaultNtoastNotifyOptions.DefaultSuccessMessage, options);

            AddMessage(toastMessage);
        }
Ejemplo n.º 3
0
        public override void AddErrorToastMessage(string message = null, ILibraryOptions toastOptions = null)
        {
            var options            = OptionsHelpers.PrepareOptionsNoty(toastOptions, message, Enums.NotificationTypesNoty.Error);
            var successNotyMessage = new NotyMessage(message ?? _defaultNtoastNotifyOptions.DefaultErrorMessage, options);

            AddMessage(successNotyMessage);
        }
Ejemplo n.º 4
0
        public static NotyOptions PrepareOptionsNoty(ILibraryOptions options, string message, NotificationTypesNoty type)
        {
            var notyOptions = CastOptionTo <NotyOptions>(options);

            notyOptions.Type = type;
            return(notyOptions);
        }
Ejemplo n.º 5
0
 public ToastrMessage(string message, string title, Enums.NotificationTypesToastr toasType, ILibraryOptions options = null)
 {
     Message      = message;
     Title        = title;
     ToastType    = toasType.ToString();
     ToastOptions = options;
 }
Ejemplo n.º 6
0
        public void ShouldSetOptions(ILibraryOptions libraryOptions, ILibraryOptions expected)
        {
            //Act
            var result = Utils.GetLibraryDetails <ToastrLibrary>(null, libraryOptions);

            //Assert
            Assert.Equal(expected.ToJson(), result.Options.ToJson());
        }
Ejemplo n.º 7
0
        public static ToastrOptions PrepareOptionsToastr(ILibraryOptions toastrOptions, NotificationTypesToastr type, string defaultTitle)
        {
            var options = CastOptionTo <ToastrOptions>(toastrOptions);

            options.Type = type;
            options.Title ??= defaultTitle;
            return(options);
        }
Ejemplo n.º 8
0
        public override void AddErrorToastMessage(string message = null, ILibraryOptions toastOptions = null)
        {
            var notyOptions = OptionsCaster.CastOptionTo <NotyOptions>(toastOptions);

            notyOptions.Type = Enums.NotificationTypesNoty.Error;
            var successNotyMessage = new NotyMessage(message ?? _defaultNtoastNotifyOptions.DefaultErrorMessage, notyOptions);

            AddMessage(successNotyMessage);
        }
Ejemplo n.º 9
0
 public override void AddAlertToastMessage(string message = null, ILibraryOptions toastrOptions = null)
 {
     //because toastr js does not have an alert type.
     AddInfoToastMessage(message, toastrOptions);
 }
Ejemplo n.º 10
0
 public abstract void AddWarningToastMessage(string message = null, ILibraryOptions toastOptions = null);
Ejemplo n.º 11
0
 public ToastViewComponent(IToastNotification toastNotification, ILibraryOptions globalOption, NToastNotifyOption nToastNotifyOption, IFileProvider fileProvider)
 {
     _toastNotification  = toastNotification;
     _globalOption       = globalOption;
     _nToastNotifyOption = nToastNotifyOption;
 }
Ejemplo n.º 12
0
        public static ILibrary GetLibraryDetails <T>(NToastNotifyOption nToastNotifyOptions, ILibraryOptions defaultOptions) where T : class, ILibrary, new()
        {
            var library = new T();

            if (nToastNotifyOptions != null)
            {
                if (!string.IsNullOrWhiteSpace(nToastNotifyOptions.ScriptSrc))
                {
                    library.ScriptSrc = nToastNotifyOptions.ScriptSrc;
                }
                if (!string.IsNullOrWhiteSpace(nToastNotifyOptions.StyleHref))
                {
                    library.StyleHref = nToastNotifyOptions.StyleHref;
                }
            }

            if (defaultOptions != null)
            {
                library.Options = defaultOptions;
            }
            return(library);
        }
Ejemplo n.º 13
0
 public NotyMessage(string message, ILibraryOptions options = null)
 {
     Message = message;
     Options = options;
 }
Ejemplo n.º 14
0
        public override void AddSuccessToastMessage(string message = null, ILibraryOptions toastOptions = null)
        {
            var toastMessage = new ToastrMessage(message ?? _defaultNtoastNotifyOptions.DefaultSuccessMessage, _defaultNtoastNotifyOptions.DefaultSuccessTitle, Enums.NotificationTypesToastr.Success, toastOptions);

            AddMessage(toastMessage);
        }
Ejemplo n.º 15
0
        public override void AddWarningToastMessage(string message = null, ILibraryOptions toasILibraryOptions = null)
        {
            var toastMessage = new ToastrMessage(message ?? _defaultNtoastNotifyOptions.DefaultWarningMessage, _defaultNtoastNotifyOptions.DefaultWarningTitle, Enums.NotificationTypesToastr.Warning, toasILibraryOptions);

            AddMessage(toastMessage);
        }