Exemple #1
0
        public static void PreLoad(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (!(type is RuntimeType))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
            }
            MethodInfo[] methods = type.GetMethods();
            foreach (MethodInfo mb in methods)
            {
                SoapServices.RegisterSoapActionForMethodBase(mb);
            }
            SoapTypeAttribute soapTypeAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type);

            if (soapTypeAttribute.IsInteropXmlElement())
            {
                SoapServices.RegisterInteropXmlElement(soapTypeAttribute.XmlElementName, soapTypeAttribute.XmlNamespace, type);
            }
            if (soapTypeAttribute.IsInteropXmlType())
            {
                SoapServices.RegisterInteropXmlType(soapTypeAttribute.XmlTypeName, soapTypeAttribute.XmlTypeNamespace, type);
            }
            int num = 0;

            SoapServices.XmlToFieldTypeMap xmlToFieldTypeMap = new SoapServices.XmlToFieldTypeMap();
            foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                SoapFieldAttribute soapFieldAttribute = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(fieldInfo);
                if (soapFieldAttribute.IsInteropXmlElement())
                {
                    string xmlElementName = soapFieldAttribute.XmlElementName;
                    string xmlNamespace   = soapFieldAttribute.XmlNamespace;
                    if (soapFieldAttribute.UseAttribute)
                    {
                        xmlToFieldTypeMap.AddXmlAttribute(fieldInfo.FieldType, fieldInfo.Name, xmlElementName, xmlNamespace);
                    }
                    else
                    {
                        xmlToFieldTypeMap.AddXmlElement(fieldInfo.FieldType, fieldInfo.Name, xmlElementName, xmlNamespace);
                    }
                    num++;
                }
            }
            if (num > 0)
            {
                SoapServices._xmlToFieldTypeMap[type] = xmlToFieldTypeMap;
            }
        }
Exemple #2
0
 /// <summary>Retrieves field type from XML attribute name, namespace, and the <see cref="T:System.Type" /> of the containing object.</summary>
 /// <param name="containingType">The <see cref="T:System.Type" /> of the object that contains the field. </param>
 /// <param name="xmlAttribute">The XML attribute name of the field type. </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>
 // Token: 0x0600558F RID: 21903 RVA: 0x0012EDF0 File Offset: 0x0012CFF0
 public static void GetInteropFieldTypeAndNameFromXmlAttribute(Type containingType, string xmlAttribute, string xmlNamespace, out Type type, out string name)
 {
     if (containingType == null)
     {
         type = null;
         name = null;
         return;
     }
     SoapServices.XmlToFieldTypeMap xmlToFieldTypeMap = (SoapServices.XmlToFieldTypeMap)SoapServices._xmlToFieldTypeMap[containingType];
     if (xmlToFieldTypeMap != null)
     {
         xmlToFieldTypeMap.GetFieldTypeAndNameFromXmlAttribute(xmlAttribute, xmlNamespace, out type, out name);
         return;
     }
     type = null;
     name = null;
 }
Exemple #3
0
 /// <summary>从 XML 特性名、命名空间和包含对象的 <see cref="T:System.Type" /> 中检索字段类型。</summary>
 /// <param name="containingType">包含该字段的对象的 <see cref="T:System.Type" />。</param>
 /// <param name="xmlAttribute">该字段类型的 XML 特性名。</param>
 /// <param name="xmlNamespace">该字段类型的 XML 命名空间。</param>
 /// <param name="type">此方法返回时,包含该字段的 <see cref="T:System.Type" />。该参数未经初始化即被传递。</param>
 /// <param name="name">此方法返回时,包含保存该字段名的 <see cref="T:System.String" />。该参数未经初始化即被传递。</param>
 /// <exception cref="T:System.Security.SecurityException">直接调用方没有基础结构权限。</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 GetInteropFieldTypeAndNameFromXmlAttribute(Type containingType, string xmlAttribute, string xmlNamespace, out Type type, out string name)
 {
     if (containingType == (Type)null)
     {
         type = (Type)null;
         name = (string)null;
     }
     else
     {
         SoapServices.XmlToFieldTypeMap xmlToFieldTypeMap = (SoapServices.XmlToFieldTypeMap)SoapServices._xmlToFieldTypeMap[(object)containingType];
         if (xmlToFieldTypeMap != null)
         {
             xmlToFieldTypeMap.GetFieldTypeAndNameFromXmlAttribute(xmlAttribute, xmlNamespace, out type, out name);
         }
         else
         {
             type = (Type)null;
             name = (string)null;
         }
     }
 }