コード例 #1
0
        public string[] GetAnsiStringsPlus
        (
            int count
        )
        {
            Sure.Positive(count, "count");

            List <string> result = new List <string>(count);
            int           index  = 0;
            string        line;

            for (; index < 1; index++)
            {
                line = GetAnsiString();
                if (ReferenceEquals(line, null))
                {
                    return(null);
                }
                result.Add(line);
            }
            for (; index < count; index++)
            {
                line = GetAnsiString();
                result.Add
                (
                    ReferenceEquals(line, null)
                        ? string.Empty
                        : line
                );
            }

            return(result.ToArray());
        }
コード例 #2
0
        public string ReadString
        (
            int length
        )
        {
            Sure.Positive(length, nameof(length));

            if (IsEOF)
            {
                return(null);
            }

            StringBuilder result = new StringBuilder(length);

            for (int i = 0; i < length; i++)
            {
                char c = ReadChar();
                if (c == EOF)
                {
                    break;
                }
                result.Append(c);
            }

            return(result.ToString());
        }
コード例 #3
0
        public static MarcRecord SetSubField
        (
            [NotNull] this MarcRecord record,
            int tag,
            int fieldOccurrence,
            char code,
            int subFieldOccurrence,
            [CanBeNull] string newValue
        )
        {
            Sure.NotNull(record, "record");
            Sure.Positive(tag, "tag");

            RecordField field = record.Fields.GetField(tag, fieldOccurrence);

            if (!ReferenceEquals(field, null))
            {
                SubField subField = field.GetSubField(code, subFieldOccurrence);
                if (!ReferenceEquals(subField, null))
                {
                    subField.Value = newValue;
                }
            }

            return(record);
        }
コード例 #4
0
        public string PeekString
        (
            int length
        )
        {
            Sure.Positive(length, nameof(length));

            if (IsEOF)
            {
                return(null);
            }

            int savePosition = _position, saveColumn = _column,
                saveLine         = _line;
            StringBuilder result = new StringBuilder(length);

            for (int i = 0; i < length; i++)
            {
                char c = ReadChar();
                if (c == EOF)
                {
                    break;
                }
                result.Append(c);
            }

            _position = savePosition;
            _column   = saveColumn;
            _line     = saveLine;

            return(result.ToString());
        }
コード例 #5
0
ファイル: CharSet.cs プロジェクト: fossabot/ManagedIrbis2
        /// <summary>
        /// Constructor.
        /// </summary>
        public CharSet
        (
            int capacity
        )
        {
            Sure.Positive(capacity, nameof(capacity));

            _data = new BitArray(capacity);
        }
コード例 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public RepeatSpecification
        (
            int index
        )
            : this()
        {
            Sure.Positive(index, nameof(index));

            Kind  = RepeatKind.Explicit;
            Index = index;
        }
コード例 #7
0
        public static IEnumerable <string> Interval
        (
            [NotNull] IIrbisConnection connection,
            [NotNull] string database,
            [NotNull] string format,
            int firstMfn,
            int lastMfn,
            int batchSize
        )
        {
            Sure.NotNull(connection, "connection");
            Sure.NotNullNorEmpty(database, "database");
            Sure.NotNullNorEmpty(format, "format");
            Sure.Positive(firstMfn, "firstMfn");
            Sure.Positive(lastMfn, "lastMfn");
            if (batchSize < 1)
            {
                Log.Error
                (
                    "BatchRecordFormatter::Interval: "
                    + "batchSize="
                    + batchSize
                );

                throw new ArgumentOutOfRangeException("batchSize");
            }

            int maxMfn = connection.GetMaxMfn(database) - 1;

            if (maxMfn == 0)
            {
                return(StringUtility.EmptyArray);
            }

            lastMfn = Math.Min(lastMfn, maxMfn);
            if (firstMfn > lastMfn)
            {
                return(StringUtility.EmptyArray);
            }

            BatchRecordFormatter result = new BatchRecordFormatter
                                          (
                connection,
                database,
                format,
                batchSize,
                Enumerable.Range(firstMfn, lastMfn - firstMfn + 1)
                                          );

            return(result);
        }
コード例 #8
0
        public static string ReadString
        (
            [NotNull] this BinaryReader reader,
            int count
        )
        {
            Sure.NotNull(reader, nameof(reader));
            Sure.Positive(count, nameof(count));

            char[] characters = reader.ReadChars(count);
            string result     = new string(characters);

            return(result);
        }
コード例 #9
0
        public char LookBehind
        (
            int distance
        )
        {
            Sure.Positive(distance, nameof(distance));

            if (_position < distance)
            {
                return(EOF);
            }

            return(_text[_position - distance]);
        }
コード例 #10
0
        /// <inheritdoc cref="IPftFormatter.FormatRecord(Int32)" />
        public string FormatRecord
        (
            int mfn
        )
        {
            Sure.Positive(mfn, "mfn");

            if (string.IsNullOrEmpty(Source))
            {
                return(string.Empty);
            }

            string result = Connection.FormatRecord(Source, mfn)
                            ?? string.Empty;

            return(result);
        }
コード例 #11
0
        public static MarcRecord SetField
        (
            [NotNull] this MarcRecord record,
            int tag,
            int occurrence,
            string newText
        )
        {
            Sure.NotNull(record, "record");
            Sure.Positive(tag, "tag");

            RecordField field = record.Fields.GetField(tag, occurrence);

            if (!ReferenceEquals(field, null))
            {
                field.SubFields.Clear();
                field.Value = newText;
            }

            return(record);
        }
コード例 #12
0
        public string[] GetUtfStrings
        (
            int count
        )
        {
            Sure.Positive(count, "count");

            List <string> result = new List <string>(count);

            for (int i = 0; i < count; i++)
            {
                string line = GetUtfString();
                if (ReferenceEquals(line, null))
                {
                    return(null);
                }
                result.Add(line);
            }

            return(result.ToArray());
        }
コード例 #13
0
        public static MarcRecord SetSubField
        (
            [NotNull] this MarcRecord record,
            int tag,
            char code,
            [CanBeNull] string newValue
        )
        {
            Sure.NotNull(record, "record");
            Sure.Positive(tag, "tag");

            RecordField field = record.Fields.GetFirstField(tag);

            if (ReferenceEquals(field, null))
            {
                field = new RecordField(tag);
                record.Fields.Add(field);
            }

            field.SetSubField(code, newValue);

            return(record);
        }
コード例 #14
0
        public static byte[] ReadBytes
        (
            [NotNull] Stream stream,
            int count
        )
        {
            Sure.NotNull(stream, "stream");
            Sure.Positive(count, "count");

            byte[] result = new byte[count];
            int    read   = stream.Read(result, 0, count);

            if (read <= 0)
            {
                return(null);
            }
            if (read != count)
            {
                Array.Resize(ref result, read);
            }

            return(result);
        }
コード例 #15
0
ファイル: SureTest.cs プロジェクト: fossabot/ManagedIrbis2
 public void Sure_Positive_4()
 {
     Sure.Positive(1.0, "argument");
 }
コード例 #16
0
ファイル: SureTest.cs プロジェクト: fossabot/ManagedIrbis2
 public void Sure_Positive_2()
 {
     Sure.Positive(1, "argument");
 }
コード例 #17
0
ファイル: SureTest.cs プロジェクト: fossabot/ManagedIrbis2
 public void Sure_Positive_5()
 {
     Sure.Positive(0L, "argument");
 }
コード例 #18
0
ファイル: SureTest.cs プロジェクト: fossabot/ManagedIrbis2
 public void Sure_Positive_3()
 {
     Sure.Positive(0.0, "argument");
 }
コード例 #19
0
ファイル: SureTest.cs プロジェクト: fossabot/ManagedIrbis2
 public void Sure_Positive_6()
 {
     Sure.Positive(1L, "argument");
 }