public static string Serialize(Assembly assembly)
        {
            var di  = new DiagnosticsInformation(assembly);
            var dic = new Dictionary <string, List <PropertyInfo> >();

            foreach (var prop in di.GetType().GetProperties())
            {
                var    cat     = prop.GetCustomAttribute <CategoryAttribute>();
                string catName = cat?.Category ?? "General";
                if (!dic.TryGetValue(catName, out List <PropertyInfo> props))
                {
                    props = new List <PropertyInfo>();
                    dic.Add(catName, props);
                }
                props.Add(prop);
            }

            var sb = new StringBuilder();

            foreach (var kv in dic)
            {
                sb.AppendLine("[" + kv.Key + "]");
                foreach (var prop in kv.Value)
                {
                    sb.AppendLine(" " + prop.Name + " = " + prop.GetValue(di));
                }
                sb.AppendLine();
            }

            return(sb.ToString());
        }
Пример #2
0
 private string GetDebugInformation() => DiagnosticsInformation.Serialize(null);