15 private class XmlEntry
19 public string Namespace;
21 public XmlEntry(
string name,
string xmlNamespace)
24 Namespace = xmlNamespace;
28 private class XmlToFieldTypeMap
30 private class FieldEntry
36 public FieldEntry(
Type type,
string name)
48 public void AddXmlElement(
Type fieldType,
string fieldName,
string xmlElement,
string xmlNamespace)
50 _elements[CreateKey(xmlElement, xmlNamespace)] =
new FieldEntry(fieldType, fieldName);
54 public void AddXmlAttribute(
Type fieldType,
string fieldName,
string xmlAttribute,
string xmlNamespace)
56 _attributes[CreateKey(xmlAttribute, xmlNamespace)] =
new FieldEntry(fieldType, fieldName);
60 public void GetFieldTypeAndNameFromXmlElement(
string xmlElement,
string xmlNamespace, out
Type type, out
string name)
62 FieldEntry fieldEntry = (FieldEntry)_elements[CreateKey(xmlElement, xmlNamespace)];
63 if (fieldEntry !=
null)
65 type = fieldEntry.Type;
66 name = fieldEntry.Name;
76 public void GetFieldTypeAndNameFromXmlAttribute(
string xmlAttribute,
string xmlNamespace, out
Type type, out
string name)
78 FieldEntry fieldEntry = (FieldEntry)_attributes[CreateKey(xmlAttribute, xmlNamespace)];
79 if (fieldEntry !=
null)
81 type = fieldEntry.Type;
82 name = fieldEntry.Name;
106 internal static string startNS =
"http://schemas.microsoft.com/clr/";
108 internal static string assemblyNS =
"http://schemas.microsoft.com/clr/assem/";
110 internal static string namespaceNS =
"http://schemas.microsoft.com/clr/ns/";
112 internal static string fullNS =
"http://schemas.microsoft.com/clr/nsassem/";
138 private static string CreateKey(
string elementName,
string elementNamespace)
140 if (elementNamespace ==
null)
144 return elementName +
" " + elementNamespace;
155 _interopXmlElementToType[CreateKey(xmlElement, xmlNamespace)] = type;
156 _interopTypeToXmlElement[type] =
new XmlEntry(xmlElement, xmlNamespace);
167 _interopXmlTypeToType[CreateKey(xmlType, xmlTypeNamespace)] = type;
168 _interopTypeToXmlType[type] =
new XmlEntry(xmlType, xmlTypeNamespace);
181 if (!(type is RuntimeType))
192 if (soapTypeAttribute.IsInteropXmlElement())
196 if (soapTypeAttribute.IsInteropXmlType())
201 XmlToFieldTypeMap xmlToFieldTypeMap =
new XmlToFieldTypeMap();
212 xmlToFieldTypeMap.AddXmlAttribute(fieldInfo.
FieldType, fieldInfo.
Name, xmlElementName, xmlNamespace);
216 xmlToFieldTypeMap.AddXmlElement(fieldInfo.
FieldType, fieldInfo.
Name, xmlElementName, xmlNamespace);
223 _xmlToFieldTypeMap[type] = xmlToFieldTypeMap;
233 if (assembly ==
null)
237 if (!(assembly is RuntimeAssembly))
242 Type[] array = types;
243 foreach (
Type type
in array)
257 return (
Type)_interopXmlElementToType[CreateKey(xmlElement, xmlNamespace)];
268 return (
Type)_interopXmlTypeToType[CreateKey(xmlType, xmlTypeNamespace)];
280 if (containingType ==
null)
286 XmlToFieldTypeMap xmlToFieldTypeMap = (XmlToFieldTypeMap)_xmlToFieldTypeMap[containingType];
287 if (xmlToFieldTypeMap !=
null)
289 xmlToFieldTypeMap.GetFieldTypeAndNameFromXmlElement(xmlElement, xmlNamespace, out type, out name);
305 if (containingType ==
null)
311 XmlToFieldTypeMap xmlToFieldTypeMap = (XmlToFieldTypeMap)_xmlToFieldTypeMap[containingType];
312 if (xmlToFieldTypeMap !=
null)
314 xmlToFieldTypeMap.GetFieldTypeAndNameFromXmlAttribute(xmlAttribute, xmlNamespace, out type, out name);
331 XmlEntry xmlEntry = (XmlEntry)_interopTypeToXmlElement[type];
332 if (xmlEntry !=
null)
334 xmlElement = xmlEntry.Name;
335 xmlNamespace = xmlEntry.Namespace;
339 if (soapTypeAttribute.IsInteropXmlElement())
360 XmlEntry xmlEntry = (XmlEntry)_interopTypeToXmlType[type];
361 if (xmlEntry !=
null)
363 xmlType = xmlEntry.Name;
364 xmlTypeNamespace = xmlEntry.Namespace;
368 if (soapTypeAttribute.IsInteropXmlType())
375 xmlTypeNamespace =
null;
408 if (soapMethodAttribute.SoapActionExplicitySet)
420 if (soapAction !=
null)
422 _methodBaseToSoapAction[mb] = soapAction;
424 if (arrayList ==
null)
426 lock (_soapActionToMethodBase)
429 _soapActionToMethodBase[soapAction] = arrayList;
443 string text = (string)_methodBaseToSoapAction[mb];
465 if (soapAction[0] ==
'"' && soapAction[soapAction.Length - 1] ==
'"')
467 soapAction = soapAction.Substring(1, soapAction.Length - 2);
470 if (
string.CompareOrdinal(soapMethodAttribute.
SoapAction, soapAction) == 0)
474 string text = (string)_methodBaseToSoapAction[mb];
475 if (text !=
null &&
string.CompareOrdinal(text, soapAction) == 0)
479 string[] array = soapAction.Split(
'#');
480 if (array.Length == 2)
482 bool assemblyIncluded;
483 string typeNameForSoapActionNamespace = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(array[0], out assemblyIncluded);
484 if (typeNameForSoapActionNamespace ==
null)
488 string value = array[1];
489 RuntimeMethodInfo runtimeMethodInfo = mb as RuntimeMethodInfo;
490 RuntimeConstructorInfo runtimeConstructorInfo = mb as RuntimeConstructorInfo;
491 RuntimeModule runtimeModule;
492 if (runtimeMethodInfo !=
null)
494 runtimeModule = runtimeMethodInfo.GetRuntimeModule();
498 if (!(runtimeConstructorInfo !=
null))
502 runtimeModule = runtimeConstructorInfo.GetRuntimeModule();
505 if (assemblyIncluded)
507 text2 = text2 +
", " + runtimeModule.GetRuntimeAssembly().GetSimpleName();
509 if (text2.Equals(typeNameForSoapActionNamespace))
511 return mb.
Name.Equals(value);
528 if (soapAction[0] ==
'"' && soapAction[soapAction.Length - 1] ==
'"')
530 soapAction = soapAction.Substring(1, soapAction.Length - 2);
533 if (arrayList !=
null)
535 if (arrayList.
Count > 1)
542 if (methodBase !=
null)
544 RuntimeMethodInfo runtimeMethodInfo = methodBase as RuntimeMethodInfo;
545 RuntimeConstructorInfo runtimeConstructorInfo = methodBase as RuntimeConstructorInfo;
546 RuntimeModule runtimeModule;
547 if (runtimeMethodInfo !=
null)
549 runtimeModule = runtimeMethodInfo.GetRuntimeModule();
553 if (!(runtimeConstructorInfo !=
null))
557 runtimeModule = runtimeConstructorInfo.GetRuntimeModule();
559 typeName = methodBase.
DeclaringType.
FullName +
", " + runtimeModule.GetRuntimeAssembly().GetSimpleName();
560 methodName = methodBase.
Name;
564 string[] array = soapAction.Split(
'#');
565 if (array.Length == 2)
567 typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(array[0], out
bool _);
568 if (typeName ==
null)
573 methodName = array[1];
605 if (IsNameNull(typeNamespace))
607 if (IsNameNull(assemblyName))
611 stringBuilder.
Append(assemblyNS);
612 UriEncode(assemblyName, stringBuilder);
614 else if (IsNameNull(assemblyName))
616 stringBuilder.
Append(namespaceNS);
617 stringBuilder.
Append(typeNamespace);
621 stringBuilder.
Append(fullNS);
622 if (typeNamespace[0] ==
'.')
624 stringBuilder.
Append(typeNamespace.Substring(1));
628 stringBuilder.
Append(typeNamespace);
630 stringBuilder.
Append(
'/');
631 UriEncode(assemblyName, stringBuilder);
647 if (IsNameNull(inNamespace))
655 assemblyName = UriDecode(inNamespace.Substring(assemblyNS.Length));
659 typeNamespace = inNamespace.Substring(namespaceNS.Length);
667 int num = inNamespace.IndexOf(
"/", fullNS.Length);
668 typeNamespace = inNamespace.Substring(fullNS.Length, num - fullNS.Length);
669 assemblyName = UriDecode(inNamespace.Substring(num + 1));
674 internal static void UriEncode(
string value,
StringBuilder sb)
676 if (value ==
null || value.Length == 0)
680 for (
int i = 0; i < value.Length; i++)
686 else if (value[i] ==
'=')
690 else if (value[i] ==
',')
701 internal static string UriDecode(
string value)
703 if (value ==
null || value.Length == 0)
708 for (
int i = 0; i < value.Length; i++)
710 if (value[i] ==
'%' && value.Length - i >= 3)
712 if (value[i + 1] ==
'2' && value[i + 2] ==
'0')
714 stringBuilder.
Append(
' ');
717 else if (value[i + 1] ==
'3' && value[i + 2] ==
'D')
719 stringBuilder.
Append(
'=');
722 else if (value[i + 1] ==
'2' && value[i + 2] ==
'C')
724 stringBuilder.
Append(
',');
729 stringBuilder.
Append(value[i]);
734 stringBuilder.
Append(value[i]);
740 private static bool IsNameNull(
string name)
742 if (name ==
null || name.Length == 0)
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
abstract Type FieldType
Gets the type of this field object.
abstract Type DeclaringType
Gets the class that declares this member.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static void PreLoad(Assembly assembly)
Preloads every T:System.Type found in the specified T:System.Reflection.Assembly from the information...
static bool IsSoapActionValidForMethodBase(string soapAction, MethodBase mb)
Determines if the specified SOAPAction is acceptable for a given T:System.Reflection....
Discovers the attributes of a method and provides access to method metadata.
abstract string FullName
Gets the fully qualified name of the type, including its namespace but not its assembly.
static string CodeXmlNamespaceForClrTypeNamespace(string typeNamespace, string assemblyName)
Returns the common language runtime type namespace name from the provided namespace and assembly name...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
static IList Synchronized(IList list)
Returns an T:System.Collections.IList wrapper that is synchronized (thread safe).
static bool DecodeXmlNamespaceForClrTypeNamespace(string inNamespace, out string typeNamespace, out string assemblyName)
Decodes the XML namespace and assembly names from the provided common language runtime namespace.
Discovers the attributes of a field and provides access to field metadata.
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
static void RegisterInteropXmlElement(string xmlElement, string xmlNamespace, Type type)
Associates the given XML element name and namespace with a run-time type that should be used for dese...
Provides several methods for using and publishing remoted objects in SOAP format.
static string XmlNsForClrTypeWithAssembly
Gets the default XML namespace prefix that should be used for XML encoding of a common language runti...
static void GetInteropFieldTypeAndNameFromXmlAttribute(Type containingType, string xmlAttribute, string xmlNamespace, out Type type, out string name)
Retrieves field type from XML attribute name, namespace, and the T:System.Type of the containing obje...
static string XmlNsForClrTypeWithNs
Gets the XML namespace prefix that should be used for XML encoding of a common language runtime class...
static string XmlNsForClrTypeWithNsAndAssembly
Gets the default XML namespace prefix that should be used for XML encoding of a common language runti...
static string GetXmlNamespaceForMethodCall(MethodBase mb)
Retrieves the XML namespace used during remote calls of the method specified in the given T:System....
static bool GetXmlElementForInteropType(Type type, out string xmlElement, out string xmlNamespace)
Returns XML element information that should be used when serializing the given type.
Provides information about, and means to manipulate, the current environment and platform....
MethodInfo [] GetMethods()
Returns all the public methods of the current T:System.Type.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
static bool IsClrTypeNamespace(string namespaceString)
Returns a Boolean value that indicates whether the specified namespace is native to the common langua...
Represents a collection of key/value pairs that are organized based on the hash code of the key....
static void PreLoad(Type type)
Preloads the given T:System.Type based on values set in a T:System.Runtime.Remoting....
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
static bool GetTypeAndMethodNameFromSoapAction(string soapAction, out string typeName, out string methodName)
Determines the type and method name of the method associated with the specified SOAPAction value.
Represents type declarations: class types, interface types, array types, value types,...
Defines utility methods for use by the .NET Framework remoting infrastructure.
static string GetXmlNamespaceForMethodResponse(MethodBase mb)
Retrieves the XML namespace used during the generation of responses to the remote call to the method ...
static Hashtable Synchronized(Hashtable table)
Returns a synchronized (thread-safe) wrapper for the T:System.Collections.Hashtable.
Provides information about methods and constructors.
abstract string Name
Gets the name of the current member.
virtual Type [] GetTypes()
Gets the types defined in this assembly.
static bool GetXmlTypeForInteropType(Type type, out string xmlType, out string xmlTypeNamespace)
Returns XML type information that should be used when serializing the given T:System....
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
static string XmlNsForClrType
Gets the XML namespace prefix for common language runtime types.
The exception that is thrown when one of the arguments provided to a method is not valid.
static void RegisterSoapActionForMethodBase(MethodBase mb, string soapAction)
Associates the provided SOAPAction value with the given T:System.Reflection.MethodBase for use in cha...
static void GetInteropFieldTypeAndNameFromXmlElement(Type containingType, string xmlElement, string xmlNamespace, out Type type, out string name)
Retrieves the T:System.Type and name of a field from the provided XML element name,...
static Type GetInteropTypeFromXmlElement(string xmlElement, string xmlNamespace)
Retrieves the T:System.Type that should be used during deserialization of an unrecognized object type...
static SoapAttribute GetCachedSoapAttribute(object reflectionObject)
Gets an appropriate SOAP-related attribute for the specified class member or method parameter.
static string GetSoapActionFromMethodBase(MethodBase mb)
Returns the SOAPAction value associated with the method specified in the given T:System....
static void RegisterInteropXmlType(string xmlType, string xmlTypeNamespace, Type type)
Associates the given XML type name and namespace with the run-time type that should be used for deser...
static void RegisterSoapActionForMethodBase(MethodBase mb)
Associates the specified T:System.Reflection.MethodBase with the SOAPAction cached with it.
static Type GetInteropTypeFromXmlType(string xmlType, string xmlTypeNamespace)
Retrieves the object T:System.Type that should be used during deserialization of an unrecognized obje...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...