/// <summary> /// Initialises or returns unmanaged pointer to BreakIterator /// </summary> /// <returns></returns> private void InitializeBreakIterator() { if (_breakIterator != IntPtr.Zero) { return; } if (_rules != null) { ErrorCode errorCode; ParseError parseError; _breakIterator = NativeMethods.ubrk_openRules(_rules, _rules.Length, Text, Text.Length, out parseError, out errorCode); if (errorCode.IsFailure()) { throw new ParseErrorException("Couldn't create RuleBasedBreakIterator with the given rules!", parseError, _rules); } } else { ErrorCode errorCode; _breakIterator = NativeMethods.ubrk_open(_iteratorType, _locale.Id, Text, Text.Length, out errorCode); if (errorCode.IsFailure()) { throw new InvalidOperationException( string.Format("Could not create a BreakIterator with locale [{0}], BreakIteratorType [{1}] and Text [{2}]", _locale.Id, _iteratorType, Text)); } } }