// Throws exception if the specified Rule does not have a valid Id. internal static SRID SapiErrorCode2SRID(SAPIErrorCodes code) { if (code >= SAPIErrorCodes.SPERR_FIRST && code <= SAPIErrorCodes.SPERR_LAST) { return((SRID)((int)SRID.SapiErrorUninitialized + (code - SAPIErrorCodes.SPERR_FIRST))); } else { switch (code) { case SAPIErrorCodes.SP_NO_RULE_ACTIVE: return(SRID.SapiErrorNoRuleActive); case SAPIErrorCodes.SP_NO_RULES_TO_ACTIVATE: return(SRID.SapiErrorNoRulesToActivate); case SAPIErrorCodes.SP_NO_PARSE_FOUND: return(SRID.NoParseFound); case SAPIErrorCodes.S_FALSE: return(SRID.UnexpectedError); default: return((SRID) unchecked (-1)); } } }
protected RegistryDataKey(string fullPath, IntPtr regHandle) { ISpRegDataKey spRegDataKey = (ISpRegDataKey) new SpDataKey(); SAPIErrorCodes sAPIErrorCodes = (SAPIErrorCodes)spRegDataKey.SetKey(regHandle, false); if (sAPIErrorCodes != 0 && sAPIErrorCodes != SAPIErrorCodes.SPERR_ALREADY_INITIALIZED) { throw new InvalidOperationException(); } _sapiRegKey = spRegDataKey; _sKeyId = fullPath; _disposeSapiKey = true; }
private static void SetProperty(ISpRecognizer sapiRecognizer, string name, object value) { SAPIErrorCodes sAPIErrorCodes = (SAPIErrorCodes)((!(value is int)) ? sapiRecognizer.SetPropertyString(name, (string)value) : sapiRecognizer.SetPropertyNum(name, (int)value)); if (sAPIErrorCodes == SAPIErrorCodes.S_FALSE) { throw new KeyNotFoundException(SR.Get(SRID.RecognizerSettingNotSupported)); } if (sAPIErrorCodes < SAPIErrorCodes.S_OK) { throw RecognizerBase.ExceptionFromSapiCreateRecognizerError(new COMException(SR.Get(SRID.RecognizerSettingUpdateError), (int)sAPIErrorCodes)); } }
protected RegistryDataKey(string fullPath, SafeRegistryHandle regHandle) { ISpRegDataKey regKey = (ISpRegDataKey) new SpDataKey(); SAPIErrorCodes hresult = (SAPIErrorCodes)regKey.SetKey(regHandle, false); regHandle?.Close(); if ((hresult != SAPIErrorCodes.S_OK) && (hresult != SAPIErrorCodes.SPERR_ALREADY_INITIALIZED)) { throw new InvalidOperationException(); } _sapiRegKey = regKey; _sKeyId = fullPath; _disposeSapiKey = true; }
internal static SRID SapiErrorCode2SRID(SAPIErrorCodes code) { if (code >= SAPIErrorCodes.SPERR_FIRST && code <= SAPIErrorCodes.SPERR_LAST) { return((SRID)(258 + (code - -2147201023))); } switch (code) { case SAPIErrorCodes.SP_NO_RULE_ACTIVE: return(SRID.SapiErrorNoRuleActive); case SAPIErrorCodes.SP_NO_RULES_TO_ACTIVATE: return(SRID.SapiErrorNoRulesToActivate); case SAPIErrorCodes.SP_NO_PARSE_FOUND: return(SRID.NoParseFound); case SAPIErrorCodes.S_FALSE: return(SRID.UnexpectedError); default: return((SRID)(-1)); } }