28 lines
		
	
	
		
			870 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			870 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| namespace EliteBGS.BGS.LogGenerator {
 | |
|     /// <summary>
 | |
|     /// Creates a generic log block, that is simply all LogEntries of type "Type"
 | |
|     /// per line
 | |
|     /// </summary>
 | |
|     /// <typeparam name="Type">LogEntry subtype to work on</typeparam>
 | |
|     public class GenericFormat<Type> : LogFormatter where Type : LogEntry {
 | |
|         public string GenerateLog(Objective objective) {
 | |
|             IEnumerable<Type> logs = objective.LogEntries.OfType<Type>().Where(x => x.IsEnabled);
 | |
|             StringBuilder builder = new StringBuilder();
 | |
| 
 | |
|             if (logs == null || logs.Count() <= 0) {
 | |
|                 return "";
 | |
|             }
 | |
| 
 | |
|             foreach (Type log in logs) {
 | |
|                 builder.AppendLine(log.ToString());
 | |
|             }
 | |
| 
 | |
|             return builder.ToString();
 | |
|         }
 | |
|     }
 | |
| }
 |