System.Runtime.Remoting.SoapServices.UriDecode C# (CSharp) Méthode

UriDecode() static private méthode

static private UriDecode ( String value ) : String
value String
Résultat String
        internal static String UriDecode(String value)
        {
            if (value == null || value.Length == 0)
                return value;

            StringBuilder sb = new StringBuilder();

            for (int i=0; i<value.Length; i++)
            {
                if (value[i] == '%' && (value.Length-i >= 3))
                {
                    if (value[i+1] == '2' && value[i+2] == '0')
                    {
                        sb.Append(' ');
                        i += 2;
                    }
                    else if (value[i+1] == '3' && value[i+2] == 'D')
                    {
                        sb.Append('=');
                        i += 2;
                    }
                    else if (value[i+1] == '2' && value[i+2] == 'C')
                    {
                        sb.Append(',');
                        i += 2;
                    }

                    else
                        sb.Append(value[i]);
                }
                else
                    sb.Append(value[i]);
            }
            return sb.ToString();
        }

Usage Example

Exemple #1
0
 public static bool DecodeXmlNamespaceForClrTypeNamespace(string inNamespace, out string typeNamespace, out string assemblyName)
 {
     if (SoapServices.IsNameNull(inNamespace))
     {
         throw new ArgumentNullException("inNamespace");
     }
     assemblyName  = 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);
 }