Helper also know type string; move to .net 10

This commit is contained in:
BlubbFish 2026-08-04 12:19:10 +02:00
parent cc579102cb
commit 7f3f3a7b89
3 changed files with 195 additions and 193 deletions

View File

@ -23,7 +23,9 @@ namespace BlubbFish.Utils {
public static void SetProperty(this Object o, String name, String value) {
PropertyInfo prop = o.GetType().GetProperty(name);
if (prop.CanWrite) {
if (prop.PropertyType == typeof(Boolean) && Boolean.TryParse(value, out Boolean vb)) {
if(prop.PropertyType == typeof(String)) {
prop.SetValue(o, value);
} else if (prop.PropertyType == typeof(Boolean) && Boolean.TryParse(value, out Boolean vb)) {
prop.SetValue(o, vb);
} else if (prop.PropertyType == typeof(Byte) && Byte.TryParse(value, out Byte v8)) {
prop.SetValue(o, v8);

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>Utils</AssemblyName>
<RootNamespace>BlubbFish.Utils</RootNamespace>
<Description>Provides useful classes for other projects</Description>