using System.Reflection; using SessionZero.SzfLib.Objects; namespace SessionZero.SzfLib.Helpers; public static class SzfHelper { public static Type? FindSzfObjectTypeByAttributeType(string szfType) { var obj = Assembly .GetExecutingAssembly() .GetTypes() .FirstOrDefault(t => t.GetCustomAttribute(typeof(SzfObjectAttribute)) is not null && t.GetCustomAttribute()?.TypeIdentifier == szfType); if (obj is null) return null; return obj.IsAbstract || obj.IsInterface ? null : obj; } public static SzfError BasicSzfValidation(ISzfObject obj) { SzfError result = new SzfError(); var metadataSection = obj.Sections.FirstOrDefault(s => s.Name == "Metadata"); if (metadataSection is null) result.AddError("No metadata section found"); if (obj.GetMetadataField("Name") == string.Empty) result.AddError("No metadata field name found"); return result; } }