private void ReleaseUnmangedResources() { if (_hunspellHandle != IntPtr.Zero) { Unamanaged.Hunspell_destroy(_hunspellHandle); _hunspellHandle = IntPtr.Zero; } }
public LinuxHunspell(string affDirectory, string dicDictory) { //Also search - /usr/share/hunspell try { _hunspellHandle = Unamanaged.Hunspell_create(affDirectory, dicDictory); } catch { System.Windows.Forms.MessageBox.Show("Unable to start hunspell spell checker - make sure hunspell is installed!"); throw; } }
private object GetDllType(Type type, string name) { IntPtr address = Unamanaged.GetProcAddress(_libDll, name); if (address != IntPtr.Zero) { return(Marshal.GetDelegateForFunctionPointer(address, type)); } return(null); }
private void ReleaseUnmangedResources() { try { if (_libVoikko != IntPtr.Zero) { _voikkoTerminate(_libVoikko); _libVoikko = IntPtr.Zero; } if (_libDll != IntPtr.Zero) { Unamanaged.FreeLibrary(_libDll); _libDll = IntPtr.Zero; } } catch { } }
public override List <string> Suggest(string word) { IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); int resultCount = Unamanaged.Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); List <string> results = new List <string>(); for (int i = 0; i < resultCount; i++) { IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * IntPtr.Size); string suggestion = Marshal.PtrToStringAuto(addressCharArray); if (!string.IsNullOrEmpty(suggestion)) { results.Add(suggestion); } } Unamanaged.Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); Marshal.FreeHGlobal(pointerToAddressStringArray); return(results); }
public override bool Spell(string word) { return(Unamanaged.Hunspell_spell(_hunspellHandle, word) != 0); }
public MacHunspell(string affDirectory, string dicDictory) { //Also search - /usr/share/hunspell _hunspellHandle = Unamanaged.Hunspell_create(affDirectory, dicDictory); }