C# Класс Google.ProtocolBuffers.FieldSet

A class which represents an arbitrary set of fields of some message type. This is used to implement DynamicMessage, and also to represent extensions in GeneratedMessage. This class is internal, since outside users should probably be using DynamicMessage. As in the Java implementation, this class goes against the rest of the framework in terms of mutability. Instead of having a mutable Builder class and an immutable FieldSet class, FieldSet just has a MakeImmutable() method. This is safe so long as all callers are careful not to let a mutable FieldSet escape into the open. This would be impossible to guarantee if this were a public class, of course. All repeated fields are stored as IList[object] even TODO(jonskeet): Finish this comment!
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
AddRepeatedField void
Clear void
FieldSet System
GetEnumerator object>>.IEnumerator
IsInitializedWithRespectTo bool
MakeImmutable FieldSet
MergeFields void
VerifyType void
this object
this object

Открытые методы

Метод Описание
ClearField ( FieldDescriptor field ) : void

See IBuilder{TMessage, TBuilder}.ClearField

CreateInstance ( ) : FieldSet
GetRepeatedFieldCount ( FieldDescriptor field ) : int

See IMessage.GetRepeatedFieldCount

HasField ( FieldDescriptor field ) : bool

See IMessage.HasField.

MergeFrom ( FieldSet other ) : void

Like MergeFrom(IMessage), but merges from another FieldSet.

MergeFrom ( IMessage other ) : void

See IBuilder{TMessage, TBuilder}.MergeFrom(IMessage)

WriteField ( FieldDescriptor field, Object value, CodedOutputStream output ) : void

Writes a single field to a CodedOutputStream.

WriteTo ( CodedOutputStream output ) : void

See IMessage.WriteTo(CodedOutputStream).

Приватные методы

Метод Описание
AddRepeatedField ( FieldDescriptor field, object value ) : void

See IBuilder{TMessage, TBuilder}.AddRepeatedField

Clear ( ) : void

Clears all fields.

FieldSet ( object>.IDictionary fields ) : System
GetEnumerator ( ) : object>>.IEnumerator

Returns an enumerator for the field map. Used to write the fields out.

IsInitializedWithRespectTo ( MessageDescriptor type ) : bool

Verifies whether all the required fields in the specified message descriptor are present in this field set, as well as whether all the embedded messages are themselves initialized.

MakeImmutable ( ) : FieldSet

Makes this FieldSet immutable, and returns it for convenience. Any mutable repeated fields are made immutable, as well as the map itself.

MergeFields ( object>.IEnumerable otherFields ) : void

Implementation of both MergeFrom methods.

VerifyType ( FieldDescriptor field, object value ) : void

Verifies that the given object is of the correct type to be a valid value for the given field.

For repeated fields, this checks if the object is of the right element type, not whether it's a list.

this ( FieldDescriptor field ) : object

See IMessage.Item(FieldDescriptor)

If the field is not set, the behaviour when fetching this property varies by field type: For singular message values, null is returned. For singular non-message values, the default value of the field is returned. For repeated values, an empty immutable list is returned. This will be compatible with IList[object], regardless of the type of the repeated item. This method returns null if the field is a singular message type and is not set; in this case it is up to the caller to fetch the message's default instance. For repeated fields of message types, an empty collection is returned. For repeated fields of non-message types, null is returned. When setting this property, any list values are copied, and each element is checked to ensure it is of an appropriate type.

this ( FieldDescriptor field, int index ) : object

See IMessage.Item(FieldDescriptor,int)

Описание методов

ClearField() публичный Метод

See IBuilder{TMessage, TBuilder}.ClearField
public ClearField ( FieldDescriptor field ) : void
field FieldDescriptor
Результат void

CreateInstance() публичный статический Метод

public static CreateInstance ( ) : FieldSet
Результат FieldSet

GetRepeatedFieldCount() публичный Метод

See IMessage.GetRepeatedFieldCount
public GetRepeatedFieldCount ( FieldDescriptor field ) : int
field FieldDescriptor
Результат int

HasField() публичный Метод

See IMessage.HasField.
public HasField ( FieldDescriptor field ) : bool
field FieldDescriptor
Результат bool

MergeFrom() публичный Метод

Like MergeFrom(IMessage), but merges from another FieldSet.
public MergeFrom ( FieldSet other ) : void
other FieldSet
Результат void

MergeFrom() публичный Метод

See IBuilder{TMessage, TBuilder}.MergeFrom(IMessage)
public MergeFrom ( IMessage other ) : void
other IMessage
Результат void

WriteField() публичный Метод

Writes a single field to a CodedOutputStream.
public WriteField ( FieldDescriptor field, Object value, CodedOutputStream output ) : void
field FieldDescriptor
value Object
output CodedOutputStream
Результат void

WriteTo() публичный Метод

See IMessage.WriteTo(CodedOutputStream).
public WriteTo ( CodedOutputStream output ) : void
output CodedOutputStream
Результат void