public NavigationBuilder Add(LocalizedString caption, string position, Action<NavigationItemBuilder> itemBuilder, IEnumerable<string> classes = null) { var childBuilder = new NavigationItemBuilder(); childBuilder.Caption(caption); childBuilder.Position(position); itemBuilder(childBuilder); Contained.AddRange(childBuilder.Build()); if (classes != null) { foreach (var className in classes) childBuilder.AddClass(className); } return this; }
public CoeverySecurityException(LocalizedString message) : base(message) { }
public NavigationBuilder Add(LocalizedString caption, IEnumerable<string> classes = null) { return Add(caption, null, x => { }, classes); }
public void OrDefault_ReturnsDefaultIfNull() { var def = new LocalizedString("test"); Assert.That(((string)null).OrDefault(def).Text, Is.SameAs("test")); }
/// <summary> /// Adds a new UI notification of type Warning /// </summary> /// <seealso cref="Coevery.UI.Notify.INotifier.Add()"/> /// <param name="message">A localized message to display</param> public static void Warning(this INotifier notifier, LocalizedString message) { notifier.Add(NotifyType.Warning, message); }
/// <summary> /// Adds a new UI notification of type Error /// </summary> /// <seealso cref="Coevery.UI.Notify.INotifier.Add()"/> /// <param name="message">A localized message to display</param> public static void Error(this INotifier notifier, LocalizedString message) { notifier.Add(NotifyType.Error, message); }
public static LocalizedString OrDefault(this string text, LocalizedString defaultValue) { return String.IsNullOrEmpty(text) ? defaultValue : new LocalizedString(text); }
public CoeveryCommandHostRetryException(LocalizedString message) : base(message) { }
public GroupInfo(LocalizedString name) { Id = name.TextHint; Name = name; }
public bool Authorize(Permission permission, IContent content, LocalizedString message) { if (_authorizationService.TryCheckAccess(permission, _workContextAccessor.GetContext().CurrentUser, content)) return true; if (message != null) { if (_workContextAccessor.GetContext().CurrentUser == null) { _notifier.Error(T("{0}. Anonymous users do not have {1} permission.", message, permission.Name)); } else { _notifier.Error(T("{0}. Current user, {2}, does not have {1} permission.", message, permission.Name, _workContextAccessor.GetContext().CurrentUser.UserName)); } } return false; }
public bool Authorize(Permission permission, LocalizedString message) { return Authorize(permission, null, message); }
public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue) { if (string.IsNullOrEmpty(text)) return defaultValue; return new LocalizedString(text); }
public void OnResultExecuting(ResultExecutingContext filterContext) { var viewResult = filterContext.Result as ViewResultBase; // if it's not a view result, a redirect for example if (viewResult == null) return; var messages = Convert.ToString(viewResult.TempData[TempDataMessages]); if (string.IsNullOrEmpty(messages)) return;// nothing to do, really var messageEntries = new List<NotifyEntry>(); foreach (var line in messages.Split(new[] { System.Environment.NewLine + "-" + System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { var delimiterIndex = line.IndexOf(':'); if (delimiterIndex != -1) { var type = (NotifyType)Enum.Parse(typeof(NotifyType), line.Substring(0, delimiterIndex)); var message = new LocalizedString(line.Substring(delimiterIndex + 1)); if (!messageEntries.Any(ne => ne.Message.TextHint == message.TextHint)) { messageEntries.Add(new NotifyEntry { Type = type, Message = message }); } } else { var message = new LocalizedString(line.Substring(delimiterIndex + 1)); if (!messageEntries.Any(ne => ne.Message.TextHint == message.TextHint)) { messageEntries.Add(new NotifyEntry { Type = NotifyType.Information, Message = message }); } } } if (!messageEntries.Any()) return; var messagesZone = _workContextAccessor.GetContext(filterContext).Layout.Zones["Messages"]; foreach(var messageEntry in messageEntries) messagesZone = messagesZone.Add(_shapeFactory.Message(messageEntry)); //todo: (heskew) probably need to keep duplicate messages from being pushed into the zone like the previous behavior //baseViewModel.Messages = baseViewModel.Messages == null ? messageEntries .Messages.Union(messageEntries).ToList(); //baseViewModel.Zones.AddRenderPartial("content:before", "Messages", baseViewModel.Messages); }
public void RegisterErrorMessage(LocalizedString message) { if (_errorMessages != null && _errorMessages.All(m => m.TextHint != message.TextHint)) { _errorMessages.Add(message); } }
public void OrDefault_ReturnsString() { var def = new LocalizedString("test"); Assert.That("bar".OrDefault(def).Text, Is.SameAs("bar")); }
public CoeverySecurityException(LocalizedString message, Exception innerException) : base(message, innerException) { }
public void Add(NotifyType type, LocalizedString message) { Logger.Information("Notification {0} message: {1}", type, message); _entries.Add(new NotifyEntry { Type = type, Message = message }); }
public CoeveryCoreException(LocalizedString message) : base(message.Text) { _localizedMessage = message; }
public CoeveryCommandHostRetryException(LocalizedString message, Exception innerException) : base(message, innerException) { }
public CoeveryCoreException(LocalizedString message, Exception innerException) : base(message.Text, innerException) { _localizedMessage = message; }
private void OutputException(TextWriter output, LocalizedString title, Exception exception) { // Display header output.WriteLine(); output.WriteLine(T("{0}", title)); // Push exceptions in a stack so we display from inner most to outer most var errors = new Stack<Exception>(); for (var scan = exception; scan != null; scan = scan.InnerException) { errors.Push(scan); } // Display inner most exception details exception = errors.Peek(); output.WriteLine(T("--------------------------------------------------------------------------------")); output.WriteLine(); output.WriteLine(T("{0}", exception.Message)); output.WriteLine(); if (!((exception is CoeveryException || exception is CoeveryCoreException) && exception.InnerException == null)) { output.WriteLine(T("Exception Details: {0}: {1}", exception.GetType().FullName, exception.Message)); output.WriteLine(); output.WriteLine(T("Stack Trace:")); output.WriteLine(); // Display exceptions from inner most to outer most foreach (var error in errors) { output.WriteLine(T("[{0}: {1}]", error.GetType().Name, error.Message)); output.WriteLine(T("{0}", error.StackTrace)); output.WriteLine(); } } // Display footer output.WriteLine("--------------------------------------------------------------------------------"); output.WriteLine(); }
public static void AddModelError(this ModelStateDictionary modelStateDictionary, string key, LocalizedString errorMessage) { modelStateDictionary.AddModelError(key, errorMessage.ToString()); }
/// <summary> /// Adds a new UI notification of type Information /// </summary> /// <seealso cref="Coevery.UI.Notify.INotifier.Add()"/> /// <param name="message">A localized message to display</param> public static void Information(this INotifier notifier, LocalizedString message) { notifier.Add(NotifyType.Information, message); }
public NavigationBuilder Add(LocalizedString caption, Action<NavigationItemBuilder> itemBuilder, IEnumerable<string> classes = null) { return Add(caption, null, itemBuilder, classes); }
public NavigationItemBuilder Caption(LocalizedString caption) { _item.Text = caption; return this; }
public void OrDefault_ReturnsDefaultForNull() { const string s = null; var def = new LocalizedString("test"); Assert.That(s.OrDefault(def).Text, Is.SameAs("test")); }