public static void Write(string line) { string where = new StackFrame(1).GetMethod().ReflectedType.ToString().Replace("Ildss.", ""); if (where.Contains('+')) { where = where.Substring(0, where.LastIndexOf('+')); } where = where.PadRight(30, ' '); _line = (DateTime.Now.ToString("hh:mm:ss:fff") + " " + where + " " + line); Save(); }
public object ViewModel(Func<object> constructor) { if (DesignMode) return constructor(); string caller = new StackFrame(1).GetMethod().Name; if (!caller.StartsWith("get_")) throw new ArgumentException("Only call ViewModel from a property getter."); string propertyName = caller.Substring(4); ForView.Initialize(); ViewModelContainer container; if (!_containerByName.TryGetValue(propertyName, out container)) { container = new ViewModelContainer(() => FirePropertyChanged(propertyName), constructor); _containerByName.Add(propertyName, container); } return container.ViewModel; }