/// <summary>Retrieves the <see cref="T:System.Type" /> and name of a field from the provided XML element name, namespace, and the containing type.</summary> /// <param name="containingType">The <see cref="T:System.Type" /> of the object that contains the field. </param> /// <param name="xmlElement">The XML element name of field. </param> /// <param name="xmlNamespace">The XML namespace of the field type. </param> /// <param name="type">When this method returns, contains a <see cref="T:System.Type" /> of the field. This parameter is passed uninitialized. </param> /// <param name="name">When this method returns, contains a <see cref="T:System.String" /> that holds the name of the field. This parameter is passed uninitialized. </param> /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static void GetInteropFieldTypeAndNameFromXmlElement(Type containingType, string xmlElement, string xmlNamespace, out Type type, out string name) { SoapServices.TypeInfo typeInfo = (SoapServices.TypeInfo)SoapServices._typeInfos[containingType]; Hashtable fields = (typeInfo == null) ? null : typeInfo.Elements; SoapServices.GetInteropFieldInfo(fields, xmlElement, xmlNamespace, out type, out name); }
/// <summary>Preloads the given <see cref="T:System.Type" /> based on values set in a <see cref="T:System.Runtime.Remoting.Metadata.SoapTypeAttribute" /> on the type.</summary> /// <param name="type">The <see cref="T:System.Type" /> to preload. </param> /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static void PreLoad(Type type) { SoapServices.TypeInfo typeInfo = SoapServices._typeInfos[type] as SoapServices.TypeInfo; if (typeInfo != null) { return; } string text; string text2; if (SoapServices.GetXmlTypeForInteropType(type, out text, out text2)) { SoapServices.RegisterInteropXmlType(text, text2, type); } if (SoapServices.GetXmlElementForInteropType(type, out text, out text2)) { SoapServices.RegisterInteropXmlElement(text, text2, type); } object syncRoot = SoapServices._typeInfos.SyncRoot; lock (syncRoot) { typeInfo = new SoapServices.TypeInfo(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { SoapFieldAttribute soapFieldAttribute = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(fieldInfo); if (soapFieldAttribute.IsInteropXmlElement()) { string nameKey = SoapServices.GetNameKey(soapFieldAttribute.XmlElementName, soapFieldAttribute.XmlNamespace); if (soapFieldAttribute.UseAttribute) { if (typeInfo.Attributes == null) { typeInfo.Attributes = new Hashtable(); } typeInfo.Attributes[nameKey] = fieldInfo; } else { if (typeInfo.Elements == null) { typeInfo.Elements = new Hashtable(); } typeInfo.Elements[nameKey] = fieldInfo; } } } SoapServices._typeInfos[type] = typeInfo; } }