コード例 #1
0
        public static RawRecord ParseMfnStatusVersion
        (
            [NotNull] string line1,
            [NotNull] string line2,
            [NotNull] RawRecord record
        )
        {
            Sure.NotNullNorEmpty(line1, nameof(line1));
            Sure.NotNullNorEmpty(line2, nameof(line2));
            Sure.NotNull(record, nameof(record));

            Regex regex = new Regex(@"^(-?\d+)\#(\d*)?");
            Match match = regex.Match(line1);

            record.Mfn = Math.Abs(int.Parse(match.Groups[1].Value));
            if (match.Groups[2].Length > 0)
            {
                record.Status = (RecordStatus)int.Parse
                                (
                    match.Groups[2].Value
                                );
            }
            match = regex.Match(line2);
            if (match.Groups[2].Length > 0)
            {
                record.Version = int.Parse(match.Groups[2].Value);
            }

            return(record);
        }
コード例 #2
0
        public static RawRecord Parse
        (
            [NotNull] string text
        )
        {
            Sure.NotNullNorEmpty(text, nameof(text));

            string[] lines = IrbisText.SplitIrbisToLines(text);

            if (lines[0] == lines[1])
            {
                lines = lines.GetSpan(1);
            }

            RawRecord result = Parse(lines);

            return(result);
        }
コード例 #3
0
        public static RawRecord Parse
        (
            [NotNull] string[] lines
        )
        {
            Sure.NotNull(lines, nameof(lines));

            if (lines.Length < 2)
            {
                Log.Error
                (
                    "RawRecord::Parse: "
                    + "text too short"
                );

                throw new IrbisException("Text too short");
            }

            string line1 = lines[0];
            string line2 = lines[1];

            lines = lines.GetSpan(2);

            RawRecord result = new RawRecord
            {
                Lines = lines
            };

            ParseMfnStatusVersion
            (
                line1,
                line2,
                result
            );

            return(result);
        }