public override TField ReadFieldBegin()
		{
			var field = new TField();
			field.Type = (TType) ReadByte();

			if (field.Type != TType.Stop)
			{
				field.ID = ReadI16();
			}

			return field;
		}
		public void Write(TProtocol oprot)
		{
			var struc = new TStruct("RestResponse");
			oprot.WriteStructBegin(struc);
			var field = new TField();
			if (__isset.status)
			{
				field.Name = "status";
				field.Type = TType.I32;
				field.ID = 1;
				oprot.WriteFieldBegin(field);
				oprot.WriteI32((int) status);
				oprot.WriteFieldEnd();
			}
			if (headers != null && __isset.headers)
			{
				field.Name = "headers";
				field.Type = TType.Map;
				field.ID = 2;
				oprot.WriteFieldBegin(field);
				{
					oprot.WriteMapBegin(new TMap(TType.String, TType.String, headers.Count));
					foreach (string _iter14 in headers.Keys)
					{
						oprot.WriteString(_iter14);
						oprot.WriteString(headers[_iter14]);
						oprot.WriteMapEnd();
					}
				}
				oprot.WriteFieldEnd();
			}
			if (body != null && __isset.body)
			{
				field.Name = "body";
				field.Type = TType.String;
				field.ID = 3;
				oprot.WriteFieldBegin(field);
				oprot.WriteBinary(body);
				oprot.WriteFieldEnd();
			}
			oprot.WriteFieldStop();
			oprot.WriteStructEnd();
		}
		public void Write(TProtocol oprot)
		{
			var struc = new TStruct("TApplicationException");
			var field = new TField();

			oprot.WriteStructBegin(struc);

			if (!String.IsNullOrEmpty(Message))
			{
				field.Name = "message";
				field.Type = TType.String;
				field.ID = 1;
				oprot.WriteFieldBegin(field);
				oprot.WriteString(Message);
				oprot.WriteFieldEnd();
			}

			field.Name = "type";
			field.Type = TType.I32;
			field.ID = 2;
			oprot.WriteFieldBegin(field);
			oprot.WriteI32((int) type);
			oprot.WriteFieldEnd();
			oprot.WriteFieldStop();
			oprot.WriteStructEnd();
		}
		public override void WriteFieldBegin(TField field)
		{
			WriteByte((byte) field.Type);
			WriteI16(field.ID);
		}
Exemple #5
0
			public void Write(TProtocol oprot)
			{
				var struc = new TStruct("execute_args");
				oprot.WriteStructBegin(struc);
				var field = new TField();
				if (request != null && __isset.request)
				{
					field.Name = "request";
					field.Type = TType.Struct;
					field.ID = 1;
					oprot.WriteFieldBegin(field);
					request.Write(oprot);
					oprot.WriteFieldEnd();
				}
				oprot.WriteFieldStop();
				oprot.WriteStructEnd();
			}
Exemple #6
0
			public void Write(TProtocol oprot)
			{
				var struc = new TStruct("execute_result");
				oprot.WriteStructBegin(struc);
				var field = new TField();

				if (__isset.success)
				{
					if (success != null)
					{
						field.Name = "success";
						field.Type = TType.Struct;
						field.ID = 0;
						oprot.WriteFieldBegin(field);
						success.Write(oprot);
						oprot.WriteFieldEnd();
					}
				}
				oprot.WriteFieldStop();
				oprot.WriteStructEnd();
			}
		public override TField ReadFieldBegin()
		{
			var field = new TField();
			byte ch = reader.Peek();
			if (ch == RBRACE[0])
			{
				field.Type = TType.Stop;
			}
			else
			{
				field.ID = (short) ReadJSONInteger();
				ReadJSONObjectStart();
				field.Type = GetTypeIDForTypeName(ReadJSONString(false));
			}
			return field;
		}
		public abstract void WriteFieldBegin(TField field);
		public override void WriteFieldBegin(TField field)
		{
			WriteJSONInteger(field.ID);
			WriteJSONObjectStart();
			WriteJSONString(GetTypeNameForTypeID(field.Type));
		}
		public void Write(TProtocol oprot)
		{
			var struc = new TStruct("RestRequest");
			oprot.WriteStructBegin(struc);
			var field = new TField();
			if (__isset.method)
			{
				field.Name = "method";
				field.Type = TType.I32;
				field.ID = 1;
				oprot.WriteFieldBegin(field);
				oprot.WriteI32((int) method);
				oprot.WriteFieldEnd();
			}
			if (uri != null && __isset.uri)
			{
				field.Name = "uri";
				field.Type = TType.String;
				field.ID = 2;
				oprot.WriteFieldBegin(field);
				oprot.WriteString(uri.PathAndQuery);
				oprot.WriteFieldEnd();
			}
			if (parameters != null && __isset.parameters)
			{
				field.Name = "parameters";
				field.Type = TType.Map;
				field.ID = 3;
				oprot.WriteFieldBegin(field);
				{
					oprot.WriteMapBegin(new TMap(TType.String, TType.String, parameters.Count));
					foreach (string _iter8 in parameters.Keys)
					{
						oprot.WriteString(_iter8);
						oprot.WriteString(parameters[_iter8]);
						oprot.WriteMapEnd();
					}
				}
				oprot.WriteFieldEnd();
			}
			if (headers != null && __isset.headers)
			{
				field.Name = "headers";
				field.Type = TType.Map;
				field.ID = 4;
				oprot.WriteFieldBegin(field);
				{
					oprot.WriteMapBegin(new TMap(TType.String, TType.String, headers.Count));
					foreach (string _iter9 in headers.Keys)
					{
						oprot.WriteString(_iter9);
						oprot.WriteString(headers[_iter9]);
						oprot.WriteMapEnd();
					}
				}
				oprot.WriteFieldEnd();
			}
			if (body != null && __isset.body)
			{
				field.Name = "body";
				field.Type = TType.String;
				field.ID = 5;
				oprot.WriteFieldBegin(field);
				oprot.WriteBinary(body);
				oprot.WriteFieldEnd();
			}
			oprot.WriteFieldStop();
			oprot.WriteStructEnd();
		}
        /**
         * Read a field header off the wire.
         */
        public override TField ReadFieldBegin()
        {
            var type = ReadByte();

            // if it's a stop, then we can return immediately, as the struct is over.
            if (type == Types.STOP)
            {
                return TSTOP;
            }

            short fieldId;

            // mask off the 4 MSB of the type header. it could contain a field id delta.
            var modifier = (short)((type & 0xf0) >> 4);
            if (modifier == 0)
            {
                // not a delta. look ahead for the zigzag varint field id.
                fieldId = ReadI16();
            }
            else
            {
                // has a delta. add the delta to the last Read field id.
                fieldId = (short)(_lastFieldId + modifier);
            }

            var field = new TField("", getTType((byte)(type & 0x0f)), fieldId);

            // if this happens to be a boolean field, the value is encoded in the type
            if (isBoolType(type))
            {
                // save the boolean value in a special instance variable.
                _boolValue = (byte)(type & 0x0f) == Types.BOOLEAN_TRUE;
            }

            // push the new field onto the field stack so we can keep the deltas going.
            _lastFieldId = field.ID;
            return field;
        }
        /**
         * The workhorse of WriteFieldBegin. It has the option of doing a
         * 'type override' of the type header. This is used specifically in the
         * boolean field case.
         */
        private void WriteFieldBeginInternal(TField field, byte typeOverride)
        {
            // short lastField = lastField_.Pop();

            // if there's a type override, use that.
            byte typeToWrite = typeOverride == 0xFF ? getCompactType(field.Type) : typeOverride;

            // check if we can use delta encoding for the field id
            if (field.ID > _lastFieldId && field.ID - _lastFieldId <= 15)
            {
                // Write them together
                WriteByteDirect((field.ID - _lastFieldId) << 4 | typeToWrite);
            }
            else
            {
                // Write them separate
                WriteByteDirect(typeToWrite);
                WriteI16(field.ID);
            }

            _lastFieldId = field.ID;
            // lastField_.push(field.id);
        }
 /**
  * Write a field header containing the field id and field type. If the
  * difference between the current field id and the last one is small (< 15),
  * then the field id will be encoded in the 4 MSB as a delta. Otherwise, the
  * field id will follow the type header as a zigzag varint.
  */
 public override void WriteFieldBegin(TField field)
 {
     if (field.Type == TType.Bool)
     {
         // we want to possibly include the value, so we'll wait.
         _booleanField = field;
     }
     else
     {
         WriteFieldBeginInternal(field, 0xFF);
     }
 }