/// <exception cref="System.IO.IOException"/> public virtual void Write(BinaryWriter writer) { if (this.value == null) { @out.WriteInt(-1); WritableUtils.WriteString(@out, this._elementType.FullName); } else { object[] array = Collections.ToArray(this.value); int length = array.Length; @out.WriteInt(length); if (length == 0) { if (this._elementType == null) { throw new NotSupportedException("Unable to serialize empty EnumSet with no element type provided." ); } WritableUtils.WriteString(@out, this._elementType.FullName); } for (int i = 0; i < length; i++) { ObjectWritable.WriteObject(@out, array[i], array[i].GetType(), _conf); } } }
/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(BinaryReader reader) { int length = @in.ReadInt(); if (length == -1) { this.value = null; } else { if (length == 0) { this._elementType = (Type)ObjectWritable.LoadClass(_conf, WritableUtils.ReadString( @in)); this.value = EnumSet.NoneOf(this._elementType); } else { E first = (E)ObjectWritable.ReadObject(@in, _conf); this.value = (EnumSet <E>)EnumSet.Of(first); for (int i = 1; i < length; i++) { this.value.AddItem((E)ObjectWritable.ReadObject(@in, _conf)); } } } }
/// <exception cref="System.IO.IOException"/> public virtual void Write(BinaryWriter writer) { @out.WriteLong(rpcVersion); UTF8.WriteString(@out, declaringClassProtocolName); UTF8.WriteString(@out, methodName); @out.WriteLong(clientVersion); @out.WriteInt(clientMethodsHash); @out.WriteInt(parameterClasses.Length); for (int i = 0; i < parameterClasses.Length; i++) { ObjectWritable.WriteObject(@out, parameters[i], parameterClasses[i], conf, true); } }
/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(BinaryReader reader) { rpcVersion = @in.ReadLong(); declaringClassProtocolName = UTF8.ReadString(@in); methodName = UTF8.ReadString(@in); clientVersion = @in.ReadLong(); clientMethodsHash = @in.ReadInt(); parameters = new object[@in.ReadInt()]; parameterClasses = new Type[parameters.Length]; ObjectWritable objectWritable = new ObjectWritable(); for (int i = 0; i < parameters.Length; i++) { parameters[i] = ObjectWritable.ReadObject(@in, objectWritable, this.conf); parameterClasses[i] = objectWritable.GetDeclaredClass(); } }