Esempio n. 1
0
        private void Display(IRequestBuilder builder)
        {
            if (builder is GroupBuilder)
            {
                foreach (IRequestBuilder rb in builder as GroupBuilder)
                {
                    Display(rb);
                }
            }
            else if (builder is MethodBuilder)
            {
                cbxMethod.SelectedValue = (builder as MethodBuilder).Method;
            }
            else if (builder is MessageTypeBuilder)
            {
                cbxType.SelectedValue = (builder as MessageTypeBuilder).MessageType;
            }
            else if (builder is TokenBuilder)
            {
                tbxToken.Text = Utils.ToHexString((builder as TokenBuilder).Token);
            }
            else if (builder is PayloadBuilder)
            {
                PayloadBuilder pb = builder as PayloadBuilder;
                if (pb.Payload != null)
                {
                    tbxPayload.Text = Utils.ToHexString(pb.Payload);
                }
                else
                {
                    tbxPayload.Text = pb.PayloadString;
                }
                cbxContentType.SelectedValue = pb.ContentType;
            }
            else if (builder is OptionBuilder)
            {
                OptionBuilder ob = builder as OptionBuilder;
                switch (ob.OptionType)
                {
                case OptionType.UriPath:
                    tbxUriPath.Text = ob.StringValue;
                    break;

                case OptionType.UriQuery:
                    tbxUriQuery.Text = ob.StringValue;
                    break;

                case OptionType.Accept:
                    cbxAccept.SelectedValue = ob.IntValue;
                    break;

                case OptionType.ContentType:
                    cbxContentType.SelectedValue = ob.IntValue;
                    break;

                case OptionType.ETag:
                    tbxETag.Text = ob.RawValue == null ? ob.StringValue : Utils.ToHexString(ob.RawValue);
                    break;

                case OptionType.IfMatch:
                    tbxIfMatch.Text = ob.RawValue == null ? ob.StringValue : Utils.ToHexString(ob.RawValue);
                    break;

                case OptionType.IfNoneMatch:
                    checkIfNoneMatch.Checked = true;
                    break;

                case OptionType.Observe:
                    tbxObserve.Text = ob.IntValue == null ? ob.StringValue : ob.IntValue.ToString();
                    break;

                case OptionType.Block2:
                    tbxBlockDown.Text = ob.IntValue == null ? ob.StringValue : ob.IntValue.ToString();
                    break;

                case OptionType.Block1:
                    tbxBlockUp.Text = ob.IntValue == null ? ob.StringValue : ob.IntValue.ToString();
                    break;

                case OptionType.LocationPath:
                    txtLocationPath.Text = ob.StringValue.ToString();
                    break;

                case OptionType.LocationQuery:
                    txtLocationQuery.Text = ob.StringValue.ToString();
                    break;

                case OptionType.MaxAge:
                    txtMaxAge.Text = ob.IntValue == null ? ob.StringValue : ob.IntValue.ToString();
                    break;

                case OptionType.ProxyScheme:
                    checkProxyScheme.Checked = true;
                    break;

                case OptionType.ProxyUri:
                    txtProxyUri.Text = ob.StringValue.ToString();
                    break;

                case OptionType.Token:
                    tbxToken.Text = ob.StringValue.ToString();
                    break;

                case OptionType.UriHost:
                    txtUriHost.Text = ob.StringValue.ToString();
                    break;

                case OptionType.UriPort:
                    txtUriPort.Text = ob.IntValue == null ? ob.StringValue : ob.IntValue.ToString();
                    break;
                }
            }
        }
Esempio n. 2
0
        public static void BuildTestCaseRequest(IRequestBuilder builder, TestCaseRequest tcRequest)
        {
            if (builder is MethodBuilder)
            {
                tcRequest.Method = (builder as MethodBuilder).Method.ToString();
            }
            else if (builder is MessageTypeBuilder)
            {
                tcRequest.MessageType = (builder as MessageTypeBuilder).MessageType.ToString();
            }
            else if (builder is TokenBuilder)
            {
                tcRequest.Token = Utils.ToHexString((builder as TokenBuilder).Token);
            }
            else if (builder is PayloadBuilder)
            {
                PayloadBuilder pb = builder as PayloadBuilder;
                if (pb.Payload != null)
                {
                    tcRequest.PayLoad = Utils.ToHexString(pb.Payload);
                }
                else
                {
                    tcRequest.PayLoad = pb.PayloadString;
                }
                tcRequest.OptionType.Content_Format = pb.ContentType.ToString();
            }

            else if (builder is OptionBuilder)
            {
                OptionBuilder ob = builder as OptionBuilder;
                switch (ob.OptionType)
                {
                case OptionType.UriPath:
                    tcRequest.OptionType.UriPath = ob.StringValue;
                    break;

                case OptionType.UriQuery:
                    tcRequest.OptionType.UriQuery = ob.StringValue;
                    break;

                case OptionType.Accept:
                    tcRequest.OptionType.Accept = ob.IntValue.ToString();
                    break;

                case OptionType.ContentType:
                    tcRequest.OptionType.Content_Format = ob.IntValue.ToString();
                    break;

                case OptionType.ETag:
                    tcRequest.OptionType.ETag = ob.RawValue == null ? ob.StringValue : Utils.ToHexString(ob.RawValue);
                    break;

                case OptionType.IfMatch:
                    tcRequest.OptionType.If_Match = ob.RawValue == null ? ob.StringValue : Utils.ToHexString(ob.RawValue);
                    break;

                case OptionType.IfNoneMatch:
                    tcRequest.OptionType.If_None_Match = "TRUE";
                    break;

                case OptionType.Observe:
                    //tcRequest.OptionType.Observe = ob.IntValue.ToString();
                    tcRequest.OptionType.Observe = ob.IntValue == null ? (ob.StringValue == null ? "" : ob.StringValue) : ob.IntValue.ToString();
                    break;

                case OptionType.Block2:
                    //tcRequest.OptionType.Block2 = ob.IntValue.ToString();
                    tcRequest.OptionType.Block2 = ob.IntValue == null ? (ob.StringValue == null ? "" : ob.StringValue) : ob.IntValue.ToString();
                    break;

                case OptionType.Block1:
                    //tcRequest.OptionType.Block1 = ob.IntValue.ToString();
                    tcRequest.OptionType.Block1 = ob.IntValue == null ? (ob.StringValue == null ? "" : ob.StringValue) : ob.IntValue.ToString();
                    break;

                case OptionType.LocationPath:
                    tcRequest.OptionType.Location_Path = ob.StringValue.ToString();
                    break;

                case OptionType.LocationQuery:
                    tcRequest.OptionType.Location_Query = ob.StringValue.ToString();
                    break;

                case OptionType.MaxAge:
                    //tcRequest.OptionType.Max_Age = ob.IntValue.ToString();
                    tcRequest.OptionType.Max_Age = ob.IntValue == null ? (ob.StringValue == null ? "" : ob.StringValue) : ob.IntValue.ToString();
                    break;

                case OptionType.ProxyScheme:
                    tcRequest.OptionType.Proxy_Scheme = "TRUE";
                    break;

                case OptionType.ProxyUri:
                    tcRequest.OptionType.Proxy_Uri = ob.StringValue.ToString();
                    break;

                case OptionType.Token:
                    tcRequest.Token = ob.StringValue.ToString();
                    break;

                case OptionType.UriHost:
                    tcRequest.OptionType.Uri_Host = ob.StringValue.ToString();
                    break;

                case OptionType.UriPort:
                    //tcRequest.OptionType.Uri_Port = ob.IntValue.ToString();
                    tcRequest.OptionType.Uri_Port = ob.IntValue == null ? (ob.StringValue == null ? "" : ob.StringValue) : ob.IntValue.ToString();
                    break;
                }
            }
        }