예제 #1
0
        // ==========================================================

        public static string GetSubFieldValue
        (
            this SubField subField
        )
        {
            return(subField == null
                       ? null
                       : subField.Value);
        }
예제 #2
0
        public static string GetFirstSubFieldValue
        (
            this RecordField field,
            char code
        )
        {
            SubField result = field.GetFirstSubField(code);

            return(ReferenceEquals(result, null)
                ? null
                : result.Value);
        }
예제 #3
0
        // ==========================================================

        public static RecordField AddSubField
        (
            this RecordField field,
            char code,
            string value
        )
        {
            SubField subField = new SubField {
                Code = code, Value = value
            };

            field.SubFields.Add(subField);

            return(field);
        }
예제 #4
0
        public static SubField[] GetSubField
        (
            this SubFieldCollection subFields,
            Action <SubField> action
        )
        {
            int count = subFields.Length;

            SubField[] result = new SubField[count];
            for (int i = 0; i < count; i++)
            {
                SubField item = subFields[i];
                result[i] = item;
                action(item);
            }

            return(result);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 public void Remove(SubField item)
 {
     _list.Remove(item);
 }
예제 #8
0
 public void Add(SubField item)
 {
     _list.Add(item);
 }