/// <summary> /// Load the specified affixFile and dictFile. /// </summary> /// <param name='affFile'> /// Affix file. /// </param> /// <param name='dictFile'> /// Dict file. /// </param> /// <exception cref='FileNotFoundException'> /// Is thrown when a file path argument specifies a file that does not exist. /// </exception> public void Load(string affFile, string dictFile) { this.WriteMessage("Load"); this.WriteMessage(affFile); this.WriteMessage(dictFile); affFile = Path.GetFullPath(affFile); if (!File.Exists(affFile)) { this.WriteMessage("affFile not found"); throw new FileNotFoundException("AFF File not found: " + affFile); } dictFile = Path.GetFullPath(dictFile); if (!File.Exists(dictFile)) { this.WriteMessage("dictFile not found"); throw new FileNotFoundException("DIC File not found: " + dictFile); } this.WriteMessage("Files found, creating spell check instance"); var overrideType = this.OverrideType; if (string.IsNullOrEmpty(overrideType)) { if (System.Environment.OSVersion.Platform == PlatformID.Unix || System.Environment.OSVersion.Platform == PlatformID.MacOSX) { overrideType = typeof(HunspellLinux).FullName; } else { if (IntPtr.Size == 4) { overrideType = typeof(HunspellWinx86).FullName; } else { overrideType = typeof(HunspellWinx64).FullName; } } } this.WriteMessage("Using type: " + overrideType); Type instanceType = Type.GetType(overrideType); if (instanceType == null || !instanceType.GetInterfaces().Contains(typeof(ISpeller))) { throw new ArgumentException("Invalid Hunspell instance type"); } this.speller = (ISpeller)Activator.CreateInstance(instanceType); this.WriteMessage("Spell check instance created"); if (this.speller != null) { this.speller.TraceFunction = (x, y) => { this.WriteMessage(x, y); }; this.speller.Init(affFile, dictFile); } this.WriteMessage("Load is complete"); }
public string СуммаПрописью (decimal summa, ISpeller language) { var sb = new StringBuilder (); sb.Append (summa.ToString ("N2")); sb.Append (' '); sb.Append (СокращенноеНаименованиеЦелойЧасти); sb.Append (' '); sb.Append ('('); int i = sb.Length; // запомнить позицию первой буквы прописи sb.Append (Прописью (Math.Floor (summa), ПолноеНаименованиеЦелойЧасти, language)); sb.Append (' '); sb.Append (Цифрами (summa * 100 % 100, ПолноеНаименованиеДробнойЧасти, language)); sb.Append (')'); sb [i] = char.ToUpper (sb [i]); // сделать первую букву прописи заглавной return sb.ToString (); }
/// <summary> /// Dispose of the instance /// </summary> /// <param name="disposing">True when called from Dispose()</param> protected virtual void Dispose(bool disposing) { if (disposing) { this.WriteMessage("Disposing"); if (!this.disposed) { if (this.speller != null) { this.speller.Free(); this.speller = null; } this.WriteMessage("About to close output writer"); this.logger.Flush(); this.disposed = true; } } }
public string СуммаПрописью(decimal summa, ISpeller language) { var sb = new StringBuilder(); sb.Append(summa.ToString("N2")); sb.Append(' '); sb.Append(СокращенноеНаименованиеЦелойЧасти); sb.Append(' '); sb.Append('('); int i = sb.Length; // запомнить позицию первой буквы прописи sb.Append(Прописью(Math.Floor(summa), ПолноеНаименованиеЦелойЧасти, language)); sb.Append(' '); sb.Append(Цифрами(summa * 100 % 100, ПолноеНаименованиеДробнойЧасти, language)); sb.Append(')'); sb [i] = char.ToUpper(sb [i]); // сделать первую букву прописи заглавной return(sb.ToString()); }
static string Цифрами(decimal n, string unit, ISpeller language) { language.Spell(n, ref unit); return(n.ToString("00") + " " + unit); }
static string Прописью(decimal n, string unit, ISpeller language) { return(language.Spell(n, ref unit) + " " + unit); }
static string Цифрами (decimal n, string unit, ISpeller language) { language.Spell (n, ref unit); return n.ToString ("00") + " " + unit; }
static string Прописью (decimal n, string unit, ISpeller language) { return language.Spell (n, ref unit) + " " + unit; }
/// <summary> /// Main constructor that supports dependency injection. /// </summary> /// <param name="speller">Any concrete implementation of ISpeller interface.</param> public SpellerEngine(ISpeller speller) { _speller = speller; }