예제 #1
0
        public static string Combine(string folder, string format, params object[] args)
        {
            var relative = TextTools.Format(format, args);
            var root     = Path.GetFullPath(folder);

            return(Path.GetFullPath(Path.Combine(root, relative)));
        }
예제 #2
0
        public void WriteLine(string format, params object[] args)
        {
            var text = TextTools.Format(format, args);

            foreach (var writer in writers)
            {
                try { writer.WriteLine(text); }
                catch (Exception) { /* IGNORE */ }
            }
        }
예제 #3
0
        public void WriteLine(string format, params object[] args)
        {
            var text = TextTools.Format(format, args);

            lock (write)
            {
                Console.Error.Write(text);
                Console.Error.Write(Environ.NewLine);
                Console.Error.Flush();
            }
        }
예제 #4
0
        public static void SetStatus(string format, params object[] args)
        {
            var text = TextTools.Format(format, args);

            lock (write)
            {
                Console.Out.Write(text);
                Console.Out.Write(Environ.NewLine);
                Console.Out.Flush();
            }

            Logger.Trace(text);
        }
예제 #5
0
 public static void Trace(string format, params object[] args)
 {
     if (TRACE != null)
     {
         var pid    = Process.GetCurrentProcess().Id;
         var text   = TextTools.Format(format, args);
         var thread = Thread.CurrentThread;
         TRACE.WriteLine("TRACE Pid:{0} Thread:{1}:{2} {3}"
                         , pid
                         , thread.ManagedThreadId
                         , thread.Name
                         , text
                         );
     }
 }
예제 #6
0
        private void Log(string format, params object[] args)
        {
            var writer = Logger.TRACE;

            if (writer != null)
            {
                var text   = TextTools.Format(format, args);
                var thread = Thread.CurrentThread;
                writer.WriteLine("Thread:{0}:{1} Disposable:{2}:{3} DC:{4} {5}"
                                 , thread.ManagedThreadId
                                 , thread.Name
                                 , GetType()
                                 , GetHashCode()
                                 , Undisposed
                                 , text
                                 );
            }
        }
예제 #7
0
        public static void SetProperty(object target, string line)
        {
            var parts = line.Split(new char[] { '=' });

            if (parts.Length != 2)
            {
                throw ExceptionTools.Make("Expected 2 parts in {0}", TextTools.Readable(line));
            }
            var propertyName  = parts[0];
            var propertyValue = parts[1];
            var property      = target.GetType().GetProperty(propertyName);

            if (property == null)
            {
                throw ExceptionTools.Make("Property not found {0}", TextTools.Readable(propertyName));
            }
            var value = Convert.ChangeType(propertyValue, property.PropertyType);

            property.SetValue(target, value, null);
        }
예제 #8
0
        public static string Relative(string format, params object[] args)
        {
            var child = TextTools.Format(format, args);

            return(Path.Combine(Directory(), child));
        }
예제 #9
0
 public static Exception Make(string format, params object[] args)
 {
     return(new Exception(TextTools.Format(format, args)));
 }