public bool DispatchCancelable(EventHandler eventHandler, object sender, CancellableEventArgs args, string eventName = null)
 {
     if (eventHandler == null)
     {
         return(args.Cancel);
     }
     eventHandler(sender, args);
     return(args.Cancel);
 }
示例#2
0
        // As of Umbraco 6.2.4 if you try to access e.Cancel for an event that isn't cancellable you'll get an exception
        static bool CheckForRefresh(IContent content, CancellableEventArgs e)
        {
            if (content.Name == PPC_2010.Data.Constants.RefreshIndicatorTitle)
            {
                ServiceLocator.Instance.Locate<IArticleRepository>().RefreshArticles();
                if (e.CanCancel)
                    e.Cancel = true;
                return true;
            }

            return false;
        }
示例#3
0
        bool CheckForRefresh(IMedia sender, CancellableEventArgs e)
        {
            // As of Umbraco 6.2.4 if you try to access e.Cancel for an event that isn't cancellable you'll get an exception
            if (sender.Name.Equals(PPC_2010.Data.Constants.RefreshIndicatorTitle, StringComparison.CurrentCultureIgnoreCase))
            {
                ServiceLocator.Instance.Locate<ISermonRepository>().RefreshSermons();
                if (e.CanCancel)
                    e.Cancel = true;
                return true;
            }

            return false;
        }
 private static void PublishErrorPage(CancellableEventArgs e, IContent content)
 {
     var helper = new UmbracoHelper(UmbracoContext.Current);
     var published = helper.TypedContent(content.Id);
     if (published != null)
     {
         var publisher = NinjectWebCommon.Kernel.GetService<IPublishingService>();
         if (publisher.PublishWebFormsPage(published.UrlWithDomain(), content.ContentType.Alias))
         {
             e.Messages.Add(new EventMessage("Success", "Static error page updated", EventMessageType.Info));
             content.SetValue(PropertyAliases.StaticPage, string.Format("/{0}.aspx", content.ContentType.Alias));
         }
         else
         {
             e.Messages.Add(new EventMessage("Error", "Failure updating static error page", EventMessageType.Error));
         }
     }
     else
     {
         e.Messages.Add(new EventMessage("Warning", "Publish again to update static error page", EventMessageType.Warning));
     }
 }