Пример #1
0
 /// <summary>
 /// Merge the values in <paramref name="other" /> into this field.  For each list
 /// of values, <paramref name="other"/>'s values are append to the ones in this
 /// field.
 /// </summary>
 internal UnknownField MergeFrom(UnknownField other)
 {
     varintList          = AddAll(varintList, other.varintList);
     fixed32List         = AddAll(fixed32List, other.fixed32List);
     fixed64List         = AddAll(fixed64List, other.fixed64List);
     lengthDelimitedList = AddAll(lengthDelimitedList, other.lengthDelimitedList);
     groupList           = AddAll(groupList, other.groupList);
     return(this);
 }
Пример #2
0
 /// <summary>
 /// Adds a field to the set. If a field with the same number already exists, it
 /// is replaced.
 /// </summary>
 internal UnknownFieldSet AddOrReplaceField(int number, UnknownField field)
 {
     if (number == 0)
     {
         throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
     }
     fields[number] = field;
     return(this);
 }
Пример #3
0
 /// <summary>
 /// Adds a field to the unknown field set. If a field with the same
 /// number already exists, the two are merged.
 /// </summary>
 private UnknownFieldSet MergeField(int number, UnknownField field)
 {
     if (number == 0)
     {
         throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
     }
     if (HasField(number))
     {
         GetOrAddField(number).MergeFrom(field);
     }
     else
     {
         AddOrReplaceField(number, field);
     }
     return(this);
 }
Пример #4
0
        private UnknownField GetOrAddField(int number)
        {
            if (lastField != null && number == lastFieldNumber)
            {
                return(lastField);
            }
            if (number == 0)
            {
                return(null);
            }

            UnknownField existing;

            if (fields.TryGetValue(number, out existing))
            {
                return(existing);
            }
            lastField = new UnknownField();
            AddOrReplaceField(number, lastField);
            lastFieldNumber = number;
            return(lastField);
        }