33 lines
		
	
	
		
			1013 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1013 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Globalization;
 | |
| using System.Reflection;
 | |
| using Newtonsoft.Json;
 | |
| 
 | |
| namespace MareSynchronos.Utils;
 | |
| 
 | |
| public static class VariousExtensions
 | |
| {
 | |
|     public static DateTime GetLinkerTime(Assembly assembly)
 | |
|     {
 | |
|         const string BuildVersionMetadataPrefix = "+build";
 | |
| 
 | |
|         var attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
 | |
|         if (attribute?.InformationalVersion != null)
 | |
|         {
 | |
|             var value = attribute.InformationalVersion;
 | |
|             var index = value.IndexOf(BuildVersionMetadataPrefix, StringComparison.Ordinal);
 | |
|             if (index > 0)
 | |
|             {
 | |
|                 value = value[(index + BuildVersionMetadataPrefix.Length)..];
 | |
|                 return DateTime.ParseExact(value, "yyyy-MM-ddTHH:mm:ss:fffZ", CultureInfo.InvariantCulture);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         return default;
 | |
|     }
 | |
| 
 | |
|     public static T DeepClone<T>(this T obj)
 | |
|     {
 | |
|         return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(obj))!;
 | |
|     }
 | |
| }
 | 
