Beispiel #1
0
 /// <summary>Decodes the XML namespace and assembly names from the provided common language runtime namespace.</summary>
 /// <returns>true if the namespace and assembly names were successfully decoded; otherwise, false.</returns>
 /// <param name="inNamespace">The common language runtime namespace. </param>
 /// <param name="typeNamespace">When this method returns, contains a <see cref="T:System.String" /> that holds the decoded namespace name. This parameter is passed uninitialized. </param>
 /// <param name="assemblyName">When this method returns, contains a <see cref="T:System.String" /> that holds the decoded assembly name. This parameter is passed uninitialized. </param>
 /// <exception cref="T:System.ArgumentNullException">The <paramref name="inNamespace" /> parameter is null or empty. </exception>
 /// <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 bool DecodeXmlNamespaceForClrTypeNamespace(string inNamespace, out string typeNamespace, out string assemblyName)
 {
     if (inNamespace == null)
     {
         throw new ArgumentNullException("inNamespace");
     }
     inNamespace   = SoapServices.DecodeNs(inNamespace);
     typeNamespace = null;
     assemblyName  = null;
     if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithNsAndAssembly))
     {
         int length = SoapServices.XmlNsForClrTypeWithNsAndAssembly.Length;
         if (length >= inNamespace.Length)
         {
             return(false);
         }
         int num = inNamespace.IndexOf('/', length + 1);
         if (num == -1)
         {
             return(false);
         }
         typeNamespace = inNamespace.Substring(length, num - length);
         assemblyName  = inNamespace.Substring(num + 1);
         return(true);
     }
     else
     {
         if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithNs))
         {
             int length2 = SoapServices.XmlNsForClrTypeWithNs.Length;
             typeNamespace = inNamespace.Substring(length2);
             return(true);
         }
         if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithAssembly))
         {
             int length3 = SoapServices.XmlNsForClrTypeWithAssembly.Length;
             assemblyName = inNamespace.Substring(length3);
             return(true);
         }
         return(false);
     }
 }