Ejemplo n.º 1
0
        /// <summary>
        ///   Identifies the corresponding status update item and adds it to the current instance.
        /// </summary>
        /// <param name = "line">The line to identify and parse.</param>
        internal void InjectLine(string line)
        {
            if (line.StartsWith("* OK"))
            {
                #region PermanentFlags

                {
                    var match = Regex.Match(line, RegexPatterns.ExaminePermanentFlagsPattern);
                    if (match.Success)
                    {
                        var matches = Regex.Matches(match.Value.Substring(14), RegexPatterns.ExamineSingleFlagOrKeywordPattern);
                        if (PermanentFlags == null)
                        {
                            PermanentFlags = new MessageFlagGroup(0x0000);
                        }
                        PermanentFlags.InjectMatches(matches);
                        return;
                    }
                }

                #endregion

                #region UidNext

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUidNextPattern);
                    if (match.Success)
                    {
                        var digit = match.Value.Split(Characters.Space)[1];
                        UidNext = int.Parse(digit);
                        return;
                    }
                }

                #endregion

                #region Unseen

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUnseenPattern);
                    if (match.Success)
                    {
                        var digit = match.Value.Split(Characters.Space)[1];
                        Unseen = int.Parse(digit);
                        return;
                    }
                }

                #endregion

                #region UidValidity

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUidValidityPattern);
                    if (match.Success)
                    {
                        var digit = match.Value.Split(Characters.Space)[1];
                        UidValidity = long.Parse(digit);
                        return;
                    }
                }

                #endregion

                return;
            }

            #region Flags

            {
                var match = Regex.Match(line, RegexPatterns.ExamineAndFetchFlagsPattern);
                if (match.Success)
                {
                    var matches = Regex.Matches(match.Value.Substring(5), RegexPatterns.ExamineSingleFlagOrKeywordPattern);
                    if (Flags == null)
                    {
                        Flags = new MessageFlagGroup(0x0000);
                    }
                    Flags.InjectMatches(matches);
                    return;
                }
            }

            #endregion

            #region Exists

            if (line.Contains("EXISTS"))
            {
                var value = Regex.Match(line, @"\d+").Value;
                Exists = int.Parse(value);
                return;
            }

            #endregion

            #region Recent

            if (line.Contains("RECENT"))
            {
                var value = Regex.Match(line, @"\d+").Value;
                Recent = int.Parse(value);
                return;
            }

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Identifies the corresponding status update item and adds it to the current instance.
        /// </summary>
        /// <param name = "line">The line to identify and parse.</param>
        internal void InjectLine(string line)
        {
            if (line.StartsWith("* OK")) {
                #region PermanentFlags

                {
                    var match = Regex.Match(line, RegexPatterns.ExaminePermanentFlagsPattern);
                    if (match.Success) {
                        var matches = Regex.Matches(match.Value.Substring(14), RegexPatterns.ExamineSingleFlagOrKeywordPattern);
                        if (PermanentFlags == null) {
                            PermanentFlags = new MessageFlagGroup(0x0000);
                        }
                        PermanentFlags.InjectMatches(matches);
                        return;
                    }
                }

                #endregion

                #region UidNext

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUidNextPattern);
                    if (match.Success) {
                        var digit = match.Value.Split(Characters.Space)[1];
                        UidNext = int.Parse(digit);
                        return;
                    }
                }

                #endregion

                #region Unseen

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUnseenPattern);
                    if (match.Success) {
                        var digit = match.Value.Split(Characters.Space)[1];
                        Unseen = int.Parse(digit);
                        return;
                    }
                }

                #endregion

                #region UidValidity

                {
                    var match = Regex.Match(line, RegexPatterns.ExamineUidValidityPattern);
                    if (match.Success) {
                        var digit = match.Value.Split(Characters.Space)[1];
                        UidValidity = long.Parse(digit);
                        return;
                    }
                }

                #endregion

                return;
            }

            #region Flags

            {
                var match = Regex.Match(line, RegexPatterns.ExamineAndFetchFlagsPattern);
                if (match.Success) {
                    var matches = Regex.Matches(match.Value.Substring(5), RegexPatterns.ExamineSingleFlagOrKeywordPattern);
                    if (Flags == null) {
                        Flags = new MessageFlagGroup(0x0000);
                    }
                    Flags.InjectMatches(matches);
                    return;
                }
            }

            #endregion

            #region Exists

            if (line.Contains("EXISTS")) {
                var value = Regex.Match(line, @"\d+").Value;
                Exists = int.Parse(value);
                return;
            }

            #endregion

            #region Recent

            if (line.Contains("RECENT")) {
                var value = Regex.Match(line, @"\d+").Value;
                Recent = int.Parse(value);
                return;
            }

            #endregion
        }
Ejemplo n.º 3
0
 public MessageState()
 {
     Flags = new MessageFlagGroup();
 }
Ejemplo n.º 4
0
 public MessageState()
 {
     Flags = new MessageFlagGroup();
 }