CSKernelClient.cUtil.setInfoString C# (CSharp) Метод

setInfoString() публичный статический Метод

public static setInfoString ( String source, String key, String value ) : String
source String
key String
value String
Результат String
        public static String setInfoString(String source, String key, String value)
        {
            key = "#" + key;

            int i = source.ToLower().IndexOf(key.ToLower(), 0);

            // the key can't apears more than one
            //
            if (source.ToLower().IndexOf(key.ToLower(), i + 1) != -1) 
            {
                throw (new Exception("cUtil.getInfoString: the key can't apears more than one.")); 
            }

            // if the key is not present we add it to the end of the string
            //
            if (i == -1)
            {
                return source + key + "=" + value + ";";
            }
            else            
            {
                const string c_errorstr = "cUtil.getInfoString: source invalid, the character {0} is not present.";

                int j = source.ToLower().IndexOf(";".ToLower(), i);
                if (j == -1) 
                { 
                    throw (new Exception(String.Format(c_errorstr, ";"))); 
                }

                int k = source.Substring(i, j-i).ToLower().IndexOf("=".ToLower(), 0);
                if (k == -1) 
                { 
                    throw (new Exception(String.Format(c_errorstr, "="))); 
                }
                k = k + i;
                return source.Substring(0, k) + value + source.Substring(j);
            }
        }