public static CalendarProperty ReadFrom(CalendarReader reader) { var line = new CalendarProperty { Name = reader.ReadName() }; if (line.Name.Length == 0) { return(line); } while (reader.PeekOrRead(';')) { var param = CalendarPropertyParameter.ReadFrom(reader); if (line.Parameters == null) { line.Parameters = new List <CalendarPropertyParameter>(); } line.Parameters.Add(param); } reader.ReadChar(':'); line.Value = ReadValue(reader); if (!reader.IsEof) { reader.ReadChar('\r'); } if (!reader.IsEof) { reader.ReadChar('\n'); } return(line); }
public static CalendarPropertyParameter ReadFrom(CalendarReader reader) { var res = new CalendarPropertyParameter { Name = reader.ReadName() }; reader.ReadChar('='); res.Values = ParseParamValues(reader); return(res); }
private static string ParseParamValue(CalendarReader reader) { StringBuilder sb = null; while (!reader.IsEof) { var ch = reader.PeekChar(); if (ch == ':' || ch == ';' || ch == ',' || ch == '"' || ch == 0x7f || (ch < 0x20 && ch != 0x09)) { return(sb?.ToString()); } ch = reader.ReadChar(); if (sb == null) { sb = new StringBuilder(); } sb.Append(ch); } return(sb?.ToString()); }
private static string ReadValue(CalendarReader reader) { var preview = reader.PeekChar(); if (preview == '"') { return(reader.ReadQuotedString()); } var sb = new StringBuilder(); while (!reader.IsEof) { var ch = reader.PeekChar(); if ((ch == '\t' || ch >= 0x20) && ch != 0x7f) { sb.Append(reader.ReadChar()); } else { return(sb.ToString()); } } return(sb.ToString()); }