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()); }
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()); }
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); }
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()); }
/// <summary> /// Constructor. /// </summary> public CharSet ( int capacity ) { Sure.Positive(capacity, nameof(capacity)); _data = new BitArray(capacity); }
/// <summary> /// Constructor. /// </summary> public RepeatSpecification ( int index ) : this() { Sure.Positive(index, nameof(index)); Kind = RepeatKind.Explicit; Index = index; }
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); }
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); }
public char LookBehind ( int distance ) { Sure.Positive(distance, nameof(distance)); if (_position < distance) { return(EOF); } return(_text[_position - distance]); }
/// <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); }
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); }
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()); }
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); }
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); }
public void Sure_Positive_4() { Sure.Positive(1.0, "argument"); }
public void Sure_Positive_2() { Sure.Positive(1, "argument"); }
public void Sure_Positive_5() { Sure.Positive(0L, "argument"); }
public void Sure_Positive_3() { Sure.Positive(0.0, "argument"); }
public void Sure_Positive_6() { Sure.Positive(1L, "argument"); }