/// <summary> /// Returns the message stored in the ExceptionMessages resource for the /// specified locale using messageOrKey and arguments passed into the /// constructor. If no string exists in the resource then this returns /// the string stored in message. (This method is identical to /// getLdapErrorMessage(Locale locale).). /// </summary> /// <param name="messageOrKey"> /// Key string for the resource. /// </param> /// <param name="arguments"> /// arguments. /// </param> /// <param name="locale"> /// The Locale that should be used to pull message /// strings out of ExceptionMessages. /// </param> /// <returns> /// the text for the message specified by the MessageKey or the Key /// if it there is no message for that key. /// </returns> public static string GetMessage(string messageOrKey, object[] arguments, CultureInfo locale) { if (_defaultLocale == null) { _defaultLocale = CultureInfo.CurrentUICulture; } if (locale == null) { locale = _defaultLocale; } if (messageOrKey == null) { messageOrKey = string.Empty; } var pattern = ExceptionMessages.GetErrorMessage(messageOrKey); // Format the message if arguments were passed if (arguments != null) { var strB = new StringBuilder(); strB.AppendFormat(pattern, arguments); pattern = strB.ToString(); // MessageFormat mf = new MessageFormat(pattern); // pattern=System.String.Format(locale,pattern,arguments); // mf.setLocale(locale); // this needs to be reset with the new local - i18n defect in java // mf.applyPattern(pattern); // pattern = mf.format(arguments); } return(pattern); }
/// <summary> Writes an LdapMessage to the Ldap server over a socket. /// /// </summary> /// <param name="info">the Message containing the message to write. /// </param> /* package */ internal void writeMessage(Message info) { ExceptionMessages em = new ExceptionMessages(); System.Object [][]contents = em.getContents(); messages.Add(info); // For bind requests, if not connected, attempt to reconnect if (info.BindRequest && (Connected == false) && ((System.Object) host != null)) { connect(host, port, info.MessageID); } if(Connected == true) { LdapMessage msg = info.Request; writeMessage(msg); return ; } else { int errorcount=0; for(errorcount=0;errorcount<contents.Length;errorcount++) if(contents[errorcount][0]=="CONNECTION_CLOSED") break; throw new LdapException(ExceptionMessages.CONNECTION_CLOSED, new System.Object[]{host, port}, LdapException.CONNECT_ERROR, (String)contents[errorcount][1]); } }