mirror of
				https://github.com/velopack/velopack.git
				synced 2025-10-25 15:19:22 +00:00 
			
		
		
		
	Rework solution structure to allow more types of library projects (#196)
* Rename avalonia & wpf samples * Rename rest of samples * fix sample readme * Fix compat util tests * rename / move all src projects * remove package lock files and move libC# again * Add rust lib and cargo workspace * Replace locksmith lib with new filelocksmith-rs library * Deprecated type * fix setup compile * Use thiserror for error handling * Rename some enums and formatting * Add missing SHA256 * wip c++ library * cpp wip * alphabetize readme * Try to get build working again * Fix some conditionally compiled bits * cross config should be in workspace root * Fix PathHelper for new rust target dir * Missed one old path to velopack.csproj * remove obsolete coverage code * testawareapp.exe no longer exists
This commit is contained in:
		
							
								
								
									
										44
									
								
								samples/CSharpAvalonia/MemoryLogger.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								samples/CSharpAvalonia/MemoryLogger.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| using System; | ||||
| using System.Text; | ||||
| using Microsoft.Extensions.Logging; | ||||
| 
 | ||||
| namespace CSharpAvalonia; | ||||
| 
 | ||||
| public class LogUpdatedEventArgs : EventArgs | ||||
| { | ||||
|     public string Text { get; set; } | ||||
| } | ||||
| 
 | ||||
| public class MemoryLogger : ILogger | ||||
| { | ||||
|     public event EventHandler<LogUpdatedEventArgs> LogUpdated; | ||||
|     private readonly StringBuilder _sb = new StringBuilder(); | ||||
| 
 | ||||
|     public IDisposable BeginScope<TState>(TState state) | ||||
|     { | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     public bool IsEnabled(LogLevel logLevel) | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) | ||||
|     { | ||||
|         lock (_sb) { | ||||
|             var message = formatter(state, exception); | ||||
|             if (exception != null) message += "\n" + exception.ToString(); | ||||
|             Console.WriteLine("log: " + message); | ||||
|             _sb.AppendLine(message); | ||||
|             LogUpdated?.Invoke(this, new LogUpdatedEventArgs { Text = _sb.ToString() }); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public override string ToString() | ||||
|     { | ||||
|         lock (_sb) { | ||||
|             return _sb.ToString(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user