Beispiel #1
0
        public static void WriteCrashReport(System.Exception ex)
        {
            String titleDate    = DateTime.Now.ToString("yyyy'-'MM'-'dd HH'-'mm'-'ss");
            String messageTitle = Utilities.RemoveSpecialCharacters(ex.Message);

            Directory.CreateDirectory(@"Log/CrashReports");
            using (var writer = new StreamWriter("Log/CrashReports/Crash " + titleDate + " - " + messageTitle.Substring(0, Math.Min(30, ex.Message.Length)) + ".txt"))
            {
                writer.Write(ComposeCrashReport(ex));
            }
        }
Beispiel #2
0
        private static string UpdateClassNameInScript(string script, string className)
        {
            var classNamePattern = new Regex(@"\s(public\s+class\s+Class_([^\s]+)\s+:\s+)\b");
            var classnameMatches = classNamePattern.Matches(script);

            if (classnameMatches.Count == 1)
            {
                string newClassName = Utilities.RemoveSpecialCharacters(className, '_');
                string oldClassName = classnameMatches[0].Groups[2].Value;
                if (!oldClassName.Equals(newClassName))
                {
                    script = script.Replace(classnameMatches[0].Groups[1].Value, String.Format("public class Class_{0} : ", newClassName)); //class declaration
                    script = script.Replace(String.Format("Class_{0}()", oldClassName), String.Format("Class_{0}()", newClassName));        //c'tors
                    Logger.Debug("Updated classname declaration in script code to: Class_" + newClassName);
                }
            }
            else
            {
                Logger.Error("Classname declaration not found in script code. Is your script code corrupted?");
            }
            return(script);
        }