internal override bool ReflectReturn() { MessagePart part = new MessagePart(); part.Name = "Body"; ReflectionContext.OutputMessage.Parts.Add(part); if (typeof(XmlNode).IsAssignableFrom(ReflectionContext.Method.ReturnType)) { MimeContentBinding mimeContentBinding = new MimeContentBinding(); mimeContentBinding.Type = "text/xml"; mimeContentBinding.Part = part.Name; ReflectionContext.OperationBinding.Output.Extensions.Add(mimeContentBinding); } else { MimeXmlBinding mimeXmlBinding = new MimeXmlBinding(); mimeXmlBinding.Part = part.Name; LogicalMethodInfo methodInfo = ReflectionContext.Method; XmlAttributes a = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = ReflectionContext.ReflectionImporter.ImportTypeMapping(methodInfo.ReturnType, a.XmlRoot); xmlTypeMapping.SetKey(methodInfo.GetKey() + ":Return"); ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); part.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); ReflectionContext.OperationBinding.Output.Extensions.Add(mimeXmlBinding); } return(true); }
internal override bool ReflectReturn() { MessagePart messagePart = new MessagePart { Name = "Body" }; base.ReflectionContext.OutputMessage.Parts.Add(messagePart); if (typeof(XmlNode).IsAssignableFrom(base.ReflectionContext.Method.ReturnType)) { MimeContentBinding extension = new MimeContentBinding { Type = "text/xml", Part = messagePart.Name }; base.ReflectionContext.OperationBinding.Output.Extensions.Add(extension); } else { MimeXmlBinding binding2 = new MimeXmlBinding { Part = messagePart.Name }; LogicalMethodInfo method = base.ReflectionContext.Method; XmlAttributes attributes = new XmlAttributes(method.ReturnTypeCustomAttributeProvider); XmlTypeMapping xmlTypeMapping = base.ReflectionContext.ReflectionImporter.ImportTypeMapping(method.ReturnType, attributes.XmlRoot); xmlTypeMapping.SetKey(method.GetKey() + ":Return"); base.ReflectionContext.SchemaExporter.ExportTypeMapping(xmlTypeMapping); messagePart.Element = new XmlQualifiedName(xmlTypeMapping.XsdElementName, xmlTypeMapping.Namespace); base.ReflectionContext.OperationBinding.Output.Extensions.Add(binding2); } return(true); }
internal static object[] GetInitializers(LogicalMethodInfo[] methodInfos) { if (methodInfos.Length == 0) { return(new object[0]); } WebServiceAttribute attribute = WebServiceReflector.GetAttribute(methodInfos); bool serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(WebServiceReflector.GetMostDerivedType(methodInfos)); XmlReflectionImporter importer = SoapReflector.CreateXmlImporter(attribute.Namespace, serviceDefaultIsEncoded); WebMethodReflector.IncludeTypes(methodInfos, importer); ArrayList list = new ArrayList(); bool[] flagArray = new bool[methodInfos.Length]; for (int i = 0; i < methodInfos.Length; i++) { LogicalMethodInfo methodInfo = methodInfos[i]; Type returnType = methodInfo.ReturnType; if (IsSupported(returnType) && HttpServerProtocol.AreUrlParametersSupported(methodInfo)) { XmlAttributes attributes = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider); XmlTypeMapping mapping = importer.ImportTypeMapping(returnType, attributes.XmlRoot); mapping.SetKey(methodInfo.GetKey() + ":Return"); list.Add(mapping); flagArray[i] = true; } } if (list.Count == 0) { return(new object[0]); } XmlMapping[] mappings = (XmlMapping[])list.ToArray(typeof(XmlMapping)); Evidence evidenceForType = GetEvidenceForType(methodInfos[0].DeclaringType); TraceMethod caller = Tracing.On ? new TraceMethod(typeof(XmlReturn), "GetInitializers", methodInfos) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId("TraceCreateSerializer"), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", new object[] { mappings, evidenceForType })); } XmlSerializer[] serializerArray = null; if (AppDomain.CurrentDomain.IsHomogenous) { serializerArray = XmlSerializer.FromMappings(mappings); } else { serializerArray = XmlSerializer.FromMappings(mappings, evidenceForType); } if (Tracing.On) { Tracing.Exit(Tracing.TraceId("TraceCreateSerializer"), caller); } object[] objArray = new object[methodInfos.Length]; int num2 = 0; for (int j = 0; j < objArray.Length; j++) { if (flagArray[j]) { objArray[j] = serializerArray[num2++]; } } return(objArray); }
internal static object[] GetInitializers(LogicalMethodInfo[] methodInfos) { if (methodInfos.Length == 0) { return(new object[0]); } WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(methodInfos); bool serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(WebServiceReflector.GetMostDerivedType(methodInfos)); XmlReflectionImporter importer = SoapReflector.CreateXmlImporter(serviceAttribute.Namespace, serviceDefaultIsEncoded); WebMethodReflector.IncludeTypes(methodInfos, importer); ArrayList mappings = new ArrayList(); bool[] supported = new bool[methodInfos.Length]; for (int i = 0; i < methodInfos.Length; i++) { LogicalMethodInfo methodInfo = methodInfos[i]; Type type = methodInfo.ReturnType; if (IsSupported(type) && HttpServerProtocol.AreUrlParametersSupported(methodInfo)) { XmlAttributes a = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider); XmlTypeMapping mapping = importer.ImportTypeMapping(type, a.XmlRoot); mapping.SetKey(methodInfo.GetKey() + ":Return"); mappings.Add(mapping); supported[i] = true; } } if (mappings.Count == 0) { return(new object[0]); } XmlMapping[] xmlMappings = (XmlMapping[])mappings.ToArray(typeof(XmlMapping)); Evidence evidence = GetEvidenceForType(methodInfos[0].DeclaringType); TraceMethod caller = Tracing.On ? new TraceMethod(typeof(XmlReturn), "GetInitializers", methodInfos) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId(Res.TraceCreateSerializer), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", xmlMappings, evidence)); } XmlSerializer[] serializers = null; if (AppDomain.CurrentDomain.IsHomogenous) { serializers = XmlSerializer.FromMappings(xmlMappings); } else { #pragma warning disable 618 // If we're in a non-homogenous domain, legacy CAS mode is enabled, so passing through evidence will not fail serializers = XmlSerializer.FromMappings(xmlMappings, evidence); #pragma warning restore 618 } if (Tracing.On) { Tracing.Exit(Tracing.TraceId(Res.TraceCreateSerializer), caller); } object[] initializers = new object[methodInfos.Length]; int count = 0; for (int i = 0; i < initializers.Length; i++) { if (supported[i]) { initializers[i] = serializers[count++]; } } return(initializers); }