DebugWrite() public static method

Debug log
public static DebugWrite ( string Message, int Verbosity = 1 ) : void
Message string
Verbosity int
return void
Beispiel #1
0
        private static Dictionary <string, string> File2Dict()
        {
            Dictionary <string, string> Values = new Dictionary <string, string>();

            string[] xx = File.ReadAllLines(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar +
                                            Paths.ConfigFile);
            string LastName = null;

            foreach (string line in xx)
            {
                string content;
                if (String.IsNullOrEmpty(line) || line.TrimStart(' ').StartsWith("//"))
                {
                    continue;
                }
                Syslog.DebugWrite("Parsing line: " + line, 8);
                if (LastName == null && line.Contains("="))
                {
                    LastName = line.Substring(0, line.IndexOf("="));
                    if (Values.ContainsKey(LastName))
                    {
                        throw new Exception("You can't redefine same value in configuration multiple times, error reading: " + LastName);
                    }
                    content = line.Substring(line.IndexOf("=") + 1);
                    if (content.Contains(";"))
                    {
                        content = content.Substring(0, content.IndexOf(";"));
                    }
                    Values.Add(LastName, content);
                    Syslog.DebugWrite("Stored config value: " + LastName + ": " + content);
                    if (line.Contains(";"))
                    {
                        LastName = null;
                    }
                    continue;
                }
                if (LastName != null)
                {
                    // we remove extra space from beginning so that we can indent in config file
                    content = line.TrimStart(' ');
                    if (!content.Contains(";"))
                    {
                        Syslog.DebugWrite("Append config value: " + LastName + ": " + content);
                        Values[LastName] += "\n" + content;
                    }
                    else
                    {
                        content           = content.Substring(0, content.IndexOf(";"));
                        Values[LastName] += "\n" + content;
                        Syslog.DebugWrite("Append config value: " + LastName + ": " + content);
                        LastName = null;
                    }
                    continue;
                }
                Syslog.WriteNow("Invalid configuration line: " + line, true);
            }
            return(Values);
        }