O'Reilly logo

.NET Design Patterns by Shine Xavier, Praseed Pai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

RxJS samples

How can we even proceed without seeing our spell checker in action on a web page? For this, we need an ASP.NET Web API that provides the suggestions. We will reuse our earlier NorvigSpellCheckerModel class as-is for this:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Net; 
    using System.Net.Http; 
    using System.Web.Http; 
    using SpellChecker; 
 
    namespace MvcApplication1.Controllers 
    { 
      public class SearchContext 
      { 
        public string Lookup { get; set; } 
        public int Count { get; set; } 
      } 
      public class ValuesController : ApiController 
      { 
        ISpellCheckerModel _spellChecker =      
        NorvigSpellCheckerModel.Instance; 
        // GET api/values 
        public IEnumerable<string> Get([FromUri] SearchContext      
        context) 
        { 
 return _spellChecker.SpellCheck(context.Lookup, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required