예제 #1
0
        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);
        }
예제 #2
0
        public static CalendarPropertyParameter ReadFrom(CalendarReader reader)
        {
            var res = new CalendarPropertyParameter {
                Name = reader.ReadName()
            };

            reader.ReadChar('=');
            res.Values = ParseParamValues(reader);
            return(res);
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }