示例#1
0
 public static bool DecodeXmlNamespaceForClrTypeNamespace(
     string inNamespace,
     out string typeNamespace,
     out string assemblyName)
 {
     if (SoapServices.IsNameNull(inNamespace))
     {
         throw new ArgumentNullException(nameof(inNamespace));
     }
     assemblyName  = (string)null;
     typeNamespace = "";
     if (inNamespace.StartsWith(SoapServices.assemblyNS, StringComparison.Ordinal))
     {
         assemblyName = SoapServices.UriDecode(inNamespace.Substring(SoapServices.assemblyNS.Length));
     }
     else if (inNamespace.StartsWith(SoapServices.namespaceNS, StringComparison.Ordinal))
     {
         typeNamespace = inNamespace.Substring(SoapServices.namespaceNS.Length);
     }
     else
     {
         if (!inNamespace.StartsWith(SoapServices.fullNS, StringComparison.Ordinal))
         {
             return(false);
         }
         int num = inNamespace.IndexOf("/", SoapServices.fullNS.Length);
         typeNamespace = inNamespace.Substring(SoapServices.fullNS.Length, num - SoapServices.fullNS.Length);
         assemblyName  = SoapServices.UriDecode(inNamespace.Substring(num + 1));
     }
     return(true);
 }
示例#2
0
        public static string CodeXmlNamespaceForClrTypeNamespace(
            string typeNamespace,
            string assemblyName)
        {
            StringBuilder sb = new StringBuilder(256);

            if (SoapServices.IsNameNull(typeNamespace))
            {
                if (SoapServices.IsNameNull(assemblyName))
                {
                    throw new ArgumentNullException("typeNamespace,assemblyName");
                }
                sb.Append(SoapServices.assemblyNS);
                SoapServices.UriEncode(assemblyName, sb);
            }
            else if (SoapServices.IsNameNull(assemblyName))
            {
                sb.Append(SoapServices.namespaceNS);
                sb.Append(typeNamespace);
            }
            else
            {
                sb.Append(SoapServices.fullNS);
                if (typeNamespace[0] == '.')
                {
                    sb.Append(typeNamespace.Substring(1));
                }
                else
                {
                    sb.Append(typeNamespace);
                }
                sb.Append('/');
                SoapServices.UriEncode(assemblyName, sb);
            }
            return(sb.ToString());
        }