// --------------------------- RunList -------------------------------- // run the List command on the server public MailDropMessages RunList( ) { MailDropMessages messages = new MailDropMessages( ); string[] listLines = null; SockEx.SendReceive("LIST" + PopConstants.CrLf); while (true) { if (ResponseIsPopTerminated(SockEx.ResponseBuilder) == true) { break; } SockEx.SleepThenReadMoreAvailableData(1000); } listLines = Stringer.Split(SockEx.ResponseMessage, NetworkConstants.CrLf); // parse the list line output into an arraylist of MailDropMessages. for (int Ix = 0; Ix < listLines.Length; ++Ix) { string line = listLines[Ix]; if ((line[0] == '+') || (line[0] == '.')) { continue; } messages.AddMessage(new MailDropMessage(line)); } return(messages); }
// convert from string to MailDropMessages public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object InValue) { if (InValue is string) { return(MailDropMessages.FromString((string)InValue)); } return(base.ConvertFrom(context, culture, InValue)); }
// Overrides the ConvertTo method of TypeConverter. public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object InValue, Type destinationType) { if (destinationType == typeof(string)) { MailDropMessages msgs = (MailDropMessages)InValue; return(msgs.ToString( )); } return(base.ConvertTo(context, culture, InValue, destinationType)); }
// ------------------------ FromString -------------------------- // create a MailDropMessages object from a comma delimeted string. public static MailDropMessages FromString(string InValue) { MailDropMessages msgs = new MailDropMessages( ); CsvString msgsLine = new CsvString( ); msgsLine.String = InValue; CsvString.Value vlu = msgsLine.BeginValue( ); while (true) { vlu.AdvanceNextValue( ); if (vlu.IsAtValue == false) { break; } CsvString line = (CsvString)vlu.ToObject( ); MailDropMessage msg = MailDropMessage.FromString(line.ToString( )); msgs.AddMessage(msg); } return(msgs); }