public object CheckWords(string data) { var serializer = new JavaScriptSerializer(); Actions args = (Actions)serializer.Deserialize(data, typeof(Actions)); if (args.RequestType == "checkWords") { baseDictionary.IgnoreAlphaNumericWords = args.Model.IgnoreAlphaNumericWords; baseDictionary.IgnoreEmailAddress = args.Model.IgnoreEmailAddress; baseDictionary.IgnoreMixedCaseWords = args.Model.IgnoreMixedCaseWords; baseDictionary.IgnoreUpperCaseWords = args.Model.IgnoreUpperCase; baseDictionary.IgnoreUrl = args.Model.IgnoreUrl; baseDictionary.IgnoreFileNames = args.Model.IgnoreFileNames; var errorWordsCollection = this.SplitWords(args.Text); return(JsonConvert.SerializeObject(errorWordsCollection)); } else if (args.RequestType == "getSuggestions") { var arr = baseDictionary.GetSuggestions(args.ErrorWord); return(JsonConvert.SerializeObject(arr)); } return(""); }
private ObservableCollection <string> GetSuggestions(string word) { var suggestions = baseDictionary.GetSuggestions(word); var suggest = new ObservableCollection <string>(); foreach (KeyValuePair <string, List <string> > pair in suggestions) { foreach (string suggestedWord in pair.Value) { suggest.Add(suggestedWord); } } return(suggest); }
public object CheckWords(string callback, string data) { var serializer = new JavaScriptSerializer(); Actions args = (Actions)serializer.Deserialize(data, typeof(Actions)); if (args.RequestType == "checkWords") { baseDictionary.IgnoreAlphaNumericWords = args.Model.IgnoreAlphaNumericWords; baseDictionary.IgnoreEmailAddress = args.Model.IgnoreEmailAddress; baseDictionary.IgnoreMixedCaseWords = args.Model.IgnoreMixedCaseWords; baseDictionary.IgnoreUpperCaseWords = args.Model.IgnoreUpperCase; baseDictionary.IgnoreUrl = args.Model.IgnoreUrl; baseDictionary.IgnoreFileNames = args.Model.IgnoreFileNames; var errorWords = this.SplitWords(args.Text); HttpContext.Current.Response.Write(string.Format("{0}({1});", callback, serializer.Serialize(errorWords))); } else if (args.RequestType == "getSuggestions") { var suggestions = baseDictionary.GetSuggestions(args.ErrorWord); HttpContext.Current.Response.Write(string.Format("{0}({1});", callback, serializer.Serialize(suggestions))); } return(string.Empty); }