Exemple #1
0
        private string ParseURLParameters(ref RESTApi restDesc, string url)
        {
            string result = url;

            if (!string.IsNullOrEmpty(url))
            {
                MatchCollection coll = Regex.Matches(result, @"\$([^$]*)\$");

                if (coll != null && coll.Count > 0)
                {
                    restDesc.UrlParameters = new List <WSParameter>();

                    int tmp = 0;
                    int i   = 0;
                    foreach (Match m in coll)
                    {
                        WSParameter prm = new WSParameter();
                        prm.Index    = i;
                        prm.Name     = "Url";
                        prm.TypeName = GetTypeName(m.Value.Trim().Replace("$", "").ToLower());

                        string newVal = "{" + i.ToString() + "}";

                        result = result.Substring(0, m.Index - tmp) + newVal + result.Substring(m.Index + m.Length - tmp);

                        i++;
                        tmp += m.Value.Length - newVal.Length;

                        restDesc.UrlParameters.Add(prm);
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        public List <WSParameter> GetParameters(Message msg)
        {
            List <WSParameter> parameters = new List <WSParameter>();

            foreach (MessagePart msgpart in msg.Parts)
            {
                if (!msgpart.Element.IsEmpty)
                {
                    XmlQualifiedName typName = msgpart.Element;

                    XmlSchemaElement lookup = (XmlSchemaElement)schemas.Find(typName, typeof(XmlSchemaElement));

                    if (lookup != null)
                    {
                        XmlSchemaComplexType tt = (XmlSchemaComplexType)lookup.SchemaType;

                        XmlSchemaSequence sequence = (XmlSchemaSequence)tt.Particle;
                        //int i = 0;
                        if (sequence != null)
                        {
                            foreach (XmlSchemaElement childElement in sequence.Items)
                            {
                                WSParameter param = new WSParameter();
                                param.Name      = childElement.Name;
                                param.TypeName  = childElement.SchemaTypeName.Name;
                                param.MinOccurs = childElement.MinOccurs;
                                param.MaxOccurs = childElement.MaxOccurs.ToString();

                                parameters.Add(param);
                                //ParameterAndType.Add(childElement.Name, childElement.SchemaTypeName.Name);
                                //Console.WriteLine("Element: {0} ,{1}", childElement.Name,childElement.SchemaTypeName.Name);
                            }
                        }
                    }
                }
                else
                {
                    WSParameter param = new WSParameter();
                    param.Name      = msgpart.Name;
                    param.TypeName  = msgpart.Type.Name;
                    param.MinOccurs = 0;
                    param.MaxOccurs = "0";

                    parameters.Add(param);
                }
            }

            return(parameters);
        }
Exemple #3
0
        private void SetParameterDefaultValue(WebServiceToInvoke wsInvoker, WSParameter wSParameter, bool isDebug)
        {
            switch (wSParameter.TypeName)
            {
            case "int":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.IntDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.IntDefaultVal);
                break;

            case "string":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.StringDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.StringDefaultVal);
                break;

            case "double":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.DoubleDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.DoubleDefaultVal);
                break;

            case "decimal":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.DecimalDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.DecimalDefaultVal);
                break;

            case "boolean":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.BooleanDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.BooleanDefaultVal);
                break;

            case "bool":
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.BooleanDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.BooleanDefaultVal);
                break;

            default:
                mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.StringDefaultVal, FontStyle.Regular, isDebug, false);
                wsInvoker.AddParameter(wSParameter.Name, DefaultValues.StringDefaultVal);
                break;
            }
        }