The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Color Coding with EntryHandlers

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Watermasysk

Posts: 661
Nickname: scottwater
Registered: Aug, 2003

Scott Watermasysk is an ASP.NET developers. He wrote the .Text blog engine.
Color Coding with EntryHandlers Posted: Mar 11, 2004 8:10 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Watermasysk.
Original Post: Color Coding with EntryHandlers
Feed Title: ScottW's ASP.NET WebLog
Feed URL: /error.aspx?aspxerrorpath=/blog/rss.aspx
Feed Description: ASP.NET and Blogging
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Watermasysk
Latest Posts From ScottW's ASP.NET WebLog

Advertisement

Thomas announced version 2.0 of his code highlighter. I have not given it a full try yet, but I thought it might be nice to point out how easy it should be to implement this in the next (0.96) version of .Text.

0.96 has a pretty simple EntryHandling system, which basically allows you to execute code before of after an Entry updated. (Posts, Articles, Comments, and Trackbacks are all entries).

The interface is still not “locked”, but for now it looks like this:

public interface IEntryFactoryHandler
{
 void Process(Entry e);
 void Configure();
}

In the web.config, you can configure:

  • The type of entires which use this handler
  • Whether the handler is valid for new or existing items (ProcessAction)
  • If the handler should process before or after connecting to the datastore (ProcessState)
  • If the handler should process synchronous or asynchronous

You should note:

  • If ProcessState = ProcessState.PreCommit, the Handler must be processed Synchronously
  • Configure will always be fired on the main thread, so any items you might need to complete Process should be set and/or referenced here.
  • Multiple ProcessAction's can be configured, but only one ProcessState can be set.

With that out of the way, we can do a quick example:

using Dottext.Framework.Components;

using Dottext.Framework.EntryHandling

using AylarSolutions.Highlight;
using AylarSolutions.Highlight.Extensions;

namespace CC
{

public class ColorCoderEntryFactoryHandler : IEntryFactoryHandler
{
public void Process(Entry e)
{
CodeBlockHighlighter highlighter = new CodeBlockHighlighter();
highlighter.InputIsHtmlEncoded = true;
e.Body = highlighter.Highlight(e.Body);
}

public void Configure(){} //nothing to set up
}
}

Read: Color Coding with EntryHandlers

Topic: Internationalization/I18n: Char.IsDigit() matches more than just "0" through "9" Previous Topic   Next Topic Topic: Sam Gentile INETA NH .NET User's Group 4/18 - Overview of .NET CLR and Friends

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use