public string GetInfo() { var builder = new StringBuilder(); builder.AppendLine("Assembly Summary"); builder.Append(Environment.NewLine); builder.AppendLine(String.Format("Name: {0}", Name)); builder.AppendLine(String.Format("Methods: {0}", MethodsCount)); builder.AppendLine(String.Format("Fields: {0}", FieldsCount)); builder.AppendLine(String.Format("Types: {0}", TypesCount)); builder.AppendLine(String.Format("Namespaces: {0}", Namespaces.Count())); // more to come return(builder.ToString()); }
protected override void ProcessRecord() { ServiceCollection services = new ServiceCollection(); services.AddDefaultCodeGen(); HashSet <string> paths = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); paths.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); paths.AddRange(AssemblyFolders); var getAssemblyTypes = new GetAssemblyTypes(paths); Type converterType = getAssemblyTypes.LoadTypeByName(Converter); if (!services.TryAddConverter(converterType)) { throw new Exception($"codegen: Error loading converter type: ${converterType}"); } var provider = services.BuildServiceProvider(); Regex regex = null; IConvertObject <Type> converter = provider.GetRequiredService(converterType) as IConvertObject <Type>; if (!string.IsNullOrEmpty(Pattern)) { regex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); } getAssemblyTypes.LoadAssemblyTypes(TargetAssembly, type => { if (!type.IsAnonymousType() && !type.IsInterface && type.IsPublic) { bool match = (Namespaces?.Count() ?? 0) == 0 || Namespaces.Contains(type.Namespace, StringComparer.InvariantCultureIgnoreCase); if (match) { match = match && (regex == null || regex.IsMatch(type.FullName)); } if (match) { var data = converter.Convert(type); WriteObject(data); } } }); }