private WsdlTypeProperty CreateDataProperty(XmlSchemaElement xElement)
        {
            var dataProp = new WsdlTypeProperty();

            dataProp.XName          = xElement.QualifiedName;
            dataProp.Documentation  = GetDocumentation(xElement.Annotation);
            dataProp.AllowNull      = xElement.MinOccurs == 0m;
            dataProp.AllowMultiple  = xElement.MaxOccurs > 1m;
            dataProp.DataType       = new WsdlType();
            dataProp.DataType.XName = xElement.ElementSchemaType.QualifiedName;
            dataProp.IsTypeProperty = dataProp.XName.Name.EndsWith(".Type");
            return(dataProp);
        }
Esempio n. 2
0
        private string GetPropertyTypeCode(WsdlTypeProperty p, bool useInterface)
        {
            var type = p.DataType.CodeName;

            if (p.AllowMultiple)
            {
                type = useInterface ? $"IEnumerable<{type}>" : $"List<{type}>";
            }
            else
            {
                if (p.AllowNull)
                {
                    if (p.DataType.IsPrimitiveType && p.DataType.CodeName != "string" && p.DataType.CodeName != "byte[]")
                    {
                        type += "?";
                    }
                }
            }
            return(type);
        }
Esempio n. 3
0
        private string GetSinglePrimitiveTypeToXmlValueExpression(WsdlTypeProperty prop, string valueExpression)
        {
            string expression = null;
            string typeName   = prop.DataType.CodeName;

            if (prop.DataType.IsEnum)
            {
                expression = $"{valueExpression}.ToXmlValue()";
            }
            else if (typeName == "string")
            {
                expression = valueExpression;
            }
            else if (typeName == "byte[]")
            {
                expression = $"Convert.ToBase64String({valueExpression})";
            }
            else
            {
                expression = $"{valueExpression}.ToString()";
            }
            return(expression);
        }
Esempio n. 4
0
        private string GetSinglePrimitiveTypeConversionExpression(WsdlTypeProperty prop, string valueExpression)
        {
            string expression = null;
            string typeName   = prop.DataType.CodeName;

            if (prop.DataType.IsEnum)
            {
                expression = $"{prop.DataType.CodeName}Extensions.Parse({valueExpression})";
            }
            else if (typeName == "string")
            {
                expression = valueExpression;
            }
            else if (typeName == "byte[]")
            {
                expression = $"Convert.FromBase64String({valueExpression})";
            }
            else
            {
                expression = $"{typeName}.Parse({valueExpression})";
            }
            return(expression);
        }