public static string GetSubFieldValue ( this RecordField field, char code, int occurrence ) { SubField result = field.GetSubField ( code, occurrence ); return(ReferenceEquals(result, null) ? null : result.Value); }
// ========================================================== public static bool HaveSubField ( this RecordField field, char code ) { SubFieldCollection subFields = field.SubFields; int count = subFields.Length; for (int i = 0; i < count; i++) { if (Utility.SameChar(subFields[i].Code, code)) { return(true); } } return(false); }
public static bool HaveSubField ( this RecordField field, params char[] codes ) { SubFieldCollection subFields = field.SubFields; int count = subFields.Length; for (int i = 0; i < count; i++) { if (Utility.OneOf(subFields[i].Code, codes)) { return(true); } } return(false); }
public static RecordField SetSubField ( this RecordField field, char code, string value ) { SubField subField = field.SubFields .Cast <SubField>() .FirstOrDefault(sub => Utility.SameChar(code, sub.Code)); if (ReferenceEquals(subField, null)) { subField = new SubField { Code = code }; field.SubFields.Add(subField); } subField.Value = value; return(field); }
internal static void ParseSingle(MarcRecord record, string[] text) { char[] delimiters = { '#' }; string line = text[0]; string[] parts = Utility.SplitString(delimiters, line); record.Mfn = int.Parse(parts[0]); if (parts.Length != 1) { record.Status = int.Parse(parts[1]); } line = text[1]; parts = line.Split(delimiters); record.Version = int.Parse(parts[1]); for (int i = 2; i < text.Length; i++) { RecordField field = RecordField.Parse(text[i]); record.Fields.Add(field); } }
public static RecordField ReplaceSubField ( this RecordField field, char code, string oldValue, string newValue ) { var found = field.SubFields .Cast <SubField>() .Where ( subField => Utility.SameChar(code, subField.Code) && Utility.SameString(oldValue, subField.Value) ); foreach (SubField subField in found) { subField.Value = newValue; } return(field); }
internal static RecordField Parse(string line) { StringReader reader = new StringReader(line); RecordField result = new RecordField(Utility.ReadTo(reader, '#')); result.Value = Utility.ReadTo(reader, '^'); while (true) { int next = reader.Read(); if (next < 0) { break; } char code = char.ToLower((char)next); string value = Utility.ReadTo(reader, '^'); SubField subField = new SubField(); subField.Code = code; subField.Value = value; result.SubFields.Add(subField); } return(result); }
public static SubField GetSubField ( this RecordField field, char code, int occurrence ) { SubFieldCollection subFields = field.SubFields; int count = subFields.Length; for (int i = 0; i < count; i++) { if (Utility.SameChar(subFields[i].Code, code)) { if (occurrence == 0) { return(subFields[i]); } occurrence--; } } return(null); }
public void Remove(RecordField item) { _list.Remove(item); }
public void Add(RecordField item) { _list.Add(item); }