Open Source .NET Development [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Open Source .NET Development [Electronic resources] - نسخه متنی

Brian Nantz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


Adding Functionality


In the original proof-of-concept, I created two example applications. The first example was a C# Console Application to take a word input and if needed return the suggestions for the correct spelling (Figure 9-5).

Figure 9-5. Console Test Application.

[View full size image]

The second application was a simple VB.NET application (Figure 9-6) that showed checking a single word in a text box and returning the results in a right-click context menu.

Figure 9-6. VB.NET Windows Form Test Application.

While these applications tested the functionality and demonstrated the cross-language capability, they really were not real-world useable applications. There are a few things that Aspell.NET needs to support before even a quality beta cycle. First, I wanted to add Log4Net to the project, even though it is somewhat simple to support good behavior if the system starts to error. This is one example where it may be useful to associate the Logger configuration with a dll. This probably warrants some changes to the code. In the meantime, ASpell.NET should just document the Log4Net requirement in the calling executables configuration file. Second, if I want to check spelling, it usually is not a single textbox field but a whole document like email or a text file, so I decided to create an application much like WordPad that is a Rich Text Format-aware editor application. Figure 9-7 shows using SharpDevelop, which is the only Open Source editor I am aware of that has a Windows Forms designer.

Figure 9-7. SharpDevelop WordpadSpell Project.

[View full size image]

While eventually I would like all the functionality of WordPad, this example application only allows for spell checking and opening a text file for spell checking. Figure 9-8 shows WordpadSpell in action.

Figure 9-8. WordpadSpell Example.

[View full size image]

Listing 9.5, a sample command-line application from the ASpell.NET distribution, shows that the API for ASpell.NET is fairly simple. The WordpadSpell is responsible for the logic to parse things down to a single word to pass to ASpell.NET for checking.

Listing 9.5. A Simple Use of ASpell.NET

try
{
string word = args[0].ToString();
aspell.net.SpellChecker spellCheck = new aspell.net.SpellChecker();
if(!spellCheck.checkword(word))
{
System.Collections.ArrayList suggestions = spellCheck.suggest(word);
foreach(string suggestion in suggestions)
{
Console.WriteLine(suggestion);
}
}
else
{
Console.WriteLine(word + " is correct");
}
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
Console.Write(ex.ToString());
}

Adding a NAnt build script is a simple copy and paste and a quick edit of the template file. When we add the project to Subversion (Figure 9-9), Draco.NET will be triggered to perform a build. The installation and iso file are created, and the successful result is emailed out.

Figure 9-9. Adding to SVN.

[View full size image]


    / 275