コード例 #1
0
        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;
        }
コード例 #2
0
 public CoeverySecurityException(LocalizedString message)
     : base(message)
 {
 }
コード例 #3
0
 public NavigationBuilder Add(LocalizedString caption, IEnumerable<string> classes = null)
 {
     return Add(caption, null, x => { }, classes);
 }
コード例 #4
0
 public void OrDefault_ReturnsDefaultIfNull()
 {
     var def = new LocalizedString("test");
     Assert.That(((string)null).OrDefault(def).Text, Is.SameAs("test"));
 }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 public static LocalizedString OrDefault(this string text, LocalizedString defaultValue)
 {
     return String.IsNullOrEmpty(text)
         ? defaultValue
         : new LocalizedString(text);
 }
 public CoeveryCommandHostRetryException(LocalizedString message)
     : base(message)
 {
 }
コード例 #9
0
 public GroupInfo(LocalizedString name)
 {
     Id = name.TextHint;
     Name = name;
 }
コード例 #10
0
        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;
        }
コード例 #11
0
 public bool Authorize(Permission permission, LocalizedString message)
 {
     return Authorize(permission, null, message);
 }
コード例 #12
0
 public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue)
 {
     if (string.IsNullOrEmpty(text))
         return defaultValue;
     return new LocalizedString(text);
 }
コード例 #13
0
        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);
        }
コード例 #14
0
 public void RegisterErrorMessage(LocalizedString message)
 {
     if (_errorMessages != null && _errorMessages.All(m => m.TextHint != message.TextHint)) {
         _errorMessages.Add(message);
     }
 }
コード例 #15
0
 public void OrDefault_ReturnsString()
 {
     var def = new LocalizedString("test");
     Assert.That("bar".OrDefault(def).Text, Is.SameAs("bar"));
 }
コード例 #16
0
 public CoeverySecurityException(LocalizedString message, Exception innerException)
     : base(message, innerException)
 {
 }
コード例 #17
0
 public void Add(NotifyType type, LocalizedString message)
 {
     Logger.Information("Notification {0} message: {1}", type, message);
     _entries.Add(new NotifyEntry { Type = type, Message = message });
 }
コード例 #18
0
 public CoeveryCoreException(LocalizedString message)
     : base(message.Text)
 {
     _localizedMessage = message;
 }
 public CoeveryCommandHostRetryException(LocalizedString message, Exception innerException)
     : base(message, innerException)
 {
 }
コード例 #20
0
 public CoeveryCoreException(LocalizedString message, Exception innerException)
     : base(message.Text, innerException)
 {
     _localizedMessage = message;
 }
コード例 #21
0
        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());
 }
コード例 #23
0
 /// <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);
 }
コード例 #24
0
 public NavigationBuilder Add(LocalizedString caption, Action<NavigationItemBuilder> itemBuilder, IEnumerable<string> classes = null)
 {
     return Add(caption, null, itemBuilder, classes);
 }
コード例 #25
0
 public NavigationItemBuilder Caption(LocalizedString caption)
 {
     _item.Text = caption;
     return this;
 }
コード例 #26
0
 public void OrDefault_ReturnsDefaultForNull()
 {
     const string s = null;
     var def = new LocalizedString("test");
     Assert.That(s.OrDefault(def).Text, Is.SameAs("test"));
 }