RegisterInteropXmlType() public static method

public static RegisterInteropXmlType ( String xmlType, String xmlTypeNamespace, Type type ) : void
xmlType String
xmlTypeNamespace String
type System.Type
return void
コード例 #1
0
 internal void StoreInteropEntries(RemotingXmlConfigFileData configData)
 {
     foreach (RemotingXmlConfigFileData.InteropXmlElementEntry entry in configData.InteropXmlElementEntries)
     {
         Type type = Assembly.Load(entry.UrtAssemblyName).GetType(entry.UrtTypeName);
         SoapServices.RegisterInteropXmlElement(entry.XmlElementName, entry.XmlElementNamespace, type);
     }
     foreach (RemotingXmlConfigFileData.InteropXmlTypeEntry entry2 in configData.InteropXmlTypeEntries)
     {
         Type type2 = Assembly.Load(entry2.UrtAssemblyName).GetType(entry2.UrtTypeName);
         SoapServices.RegisterInteropXmlType(entry2.XmlTypeName, entry2.XmlTypeNamespace, type2);
     }
     foreach (RemotingXmlConfigFileData.PreLoadEntry entry3 in configData.PreLoadEntries)
     {
         Assembly assembly = Assembly.Load(entry3.AssemblyName);
         if (entry3.TypeName != null)
         {
             SoapServices.PreLoad(assembly.GetType(entry3.TypeName));
         }
         else
         {
             SoapServices.PreLoad(assembly);
         }
     }
 }
コード例 #2
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;
            }
        }
コード例 #3
0
        /// <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;
            }
        }
コード例 #4
0
        void ReadInteropXml(SmallXmlParser.IAttrList attrs, bool isElement)
        {
            Type t = Type.GetType(GetNotNull(attrs, "clr"));

            string[] xmlName   = GetNotNull(attrs, "xml").Split(',');
            string   localName = xmlName [0].Trim();
            string   ns        = xmlName.Length > 0 ? xmlName[1].Trim() : null;

            if (isElement)
            {
                SoapServices.RegisterInteropXmlElement(localName, ns, t);
            }
            else
            {
                SoapServices.RegisterInteropXmlType(localName, ns, t);
            }
        }
コード例 #5
0
        private void ReadInteropXml(SmallXmlParser.IAttrList attrs, bool isElement)
        {
            Type type = Type.GetType(this.GetNotNull(attrs, "clr"));

            string[] array = this.GetNotNull(attrs, "xml").Split(new char[]
            {
                ','
            });
            string text  = array[0].Trim();
            string text2 = (array.Length <= 0) ? null : array[1].Trim();

            if (isElement)
            {
                SoapServices.RegisterInteropXmlElement(text, text2, type);
            }
            else
            {
                SoapServices.RegisterInteropXmlType(text, text2, type);
            }
        }