private XElement CreateElement(PropertyInfo property) { string name = MagickTypes.GetXsdName(property); string attributeTypeName = MagickTypes.GetXsdAttributeType(property); if (attributeTypeName != null) { XElement complexType = new XElement(_Namespace + "complexType"); complexType.Add(new XElement(_Namespace + "attribute", new XAttribute("name", "value"), new XAttribute("use", "required"), new XAttribute("type", attributeTypeName))); return(new XElement(_Namespace + "element", new XAttribute("name", name), complexType)); } else { return(new XElement(_Namespace + "element", new XAttribute("name", name), new XAttribute("type", MagickTypes.GetXsdElementType(property)))); } }
private void AddParameterElements(XElement complexType, ParameterInfo[] parameters, string[] requiredParameters) { XElement sequence = new XElement(_Namespace + "sequence"); foreach (var parameter in from parameter in parameters let typeName = MagickTypes.GetXsdElementType(parameter) where typeName != null orderby parameter.Name select new { Name = parameter.Name, TypeName = typeName, IsRequired = requiredParameters.Contains(parameter.Name) }) { XElement element = new XElement(_Namespace + "element", new XAttribute("name", parameter.Name)); if (!parameter.IsRequired) { element.Add(new XAttribute("minOccurs", "0")); } element.Add(new XAttribute("type", parameter.TypeName)); sequence.Add(element); } if (sequence.HasElements) { complexType.Add(sequence); } }
private XElement CreateElement(PropertyInfo property) { string name = MagickTypes.GetXsdName(property); string attributeTypeName = MagickTypes.GetXsdAttributeType(property); if (attributeTypeName != null) { XElement complexType = new XElement(_Namespace + "complexType"); complexType.Add(new XElement(_Namespace + "attribute", new XAttribute("name", "value"), new XAttribute("use", "required"), new XAttribute("type", attributeTypeName))); return(new XElement(_Namespace + "element", new XAttribute("name", name), complexType)); } else { string elementTypeName = MagickTypes.GetXsdElementType(property); if (string.IsNullOrEmpty(elementTypeName)) { throw new NotImplementedException("CreateElement: " + name); } return(new XElement(_Namespace + "element", new XAttribute("name", name), new XAttribute("type", elementTypeName))); } }
private void AddMethods(XElement element, IEnumerable <MethodBase> methods) { ParameterInfo[] parameters = (from method in methods from parameter in method.GetParameters() select parameter).ToArray(); if (parameters.Length == 0) { element.Add(new XAttribute("type", "empty")); return; } if (methods.Count() == 1 && IsTypedElement(methods.First(), parameters)) { string elementTypeName = MagickTypes.GetXsdElementType(parameters[0]); if (string.IsNullOrEmpty(elementTypeName)) { throw new NotImplementedException("AddMethods: " + methods.First().Name); } element.Add(new XAttribute("type", elementTypeName)); return; } XElement complexType = new XElement(_Namespace + "complexType"); AddArguments(complexType, methods); element.Add(complexType); }
private void AddClassElements(XElement complexType, IEnumerable <PropertyInfo> properties, IEnumerable <MethodInfo> methods) { XElement sequence = new XElement(_Namespace + "sequence"); foreach (var property in from property in properties let typeName = MagickTypes.GetXsdElementType(property) where typeName != null let name = MagickTypes.GetXsdName(property) orderby name select new { Name = name, TypeName = typeName }) { XElement element = new XElement(_Namespace + "element", new XAttribute("name", property.Name), new XAttribute("minOccurs", "0")); element.Add(new XAttribute("type", property.TypeName)); sequence.Add(element); } if (methods.Count() > 0) { foreach (MethodBase method in methods) { XElement element = new XElement(_Namespace + "element", new XAttribute("name", MagickTypes.GetXsdName(methods.First())), new XAttribute("minOccurs", "0"), new XAttribute("maxOccurs", "unbounded")); AddMethods(element, new MethodBase[] { method }); sequence.Add(element); } } if (sequence.HasElements) { complexType.Add(sequence); } }
private void AddMethods(XElement element, IEnumerable <MethodBase> methods) { ParameterInfo[] parameters = (from method in methods from parameter in method.GetParameters() select parameter).ToArray(); if (parameters.Length == 0) { element.Add(new XAttribute("type", "empty")); return; } if (methods.Count() == 1 && IsTypedElement(methods.First(), parameters)) { element.Add(new XAttribute("type", MagickTypes.GetXsdElementType(parameters[0]))); return; } XElement complexType = new XElement(_Namespace + "complexType"); AddArguments(complexType, methods); element.Add(complexType); }