in src/ApiPort/ApiPort.VisualStudio/ServiceProvider.cs [47:140]
public static async Task<ServiceProvider> CreateAsync(ApiPortVSPackage serviceProvider)
{
var builder = new ContainerBuilder();
builder.RegisterType<VsBrowserReportViewer>()
.As<IReportViewer>()
.SingleInstance();
builder.RegisterType<ToolbarListReportViewer>()
.As<IReportViewer>()
.InstancePerLifetimeScope();
builder.RegisterType<ApiPortVsAnalyzer>()
.As<IVsApiPortAnalyzer>()
.InstancePerLifetimeScope();
// Service registration
builder.RegisterInstance(new ProductInformation("ApiPort_VS"))
.AsSelf();
builder.RegisterInstance(new AssemblyRedirectResolver(AssemblyDirectory))
.AsSelf();
builder.RegisterType<VisualStudioProxyProvider>()
.As<IProxyProvider>()
.SingleInstance();
builder.RegisterType<ApiPortService>()
.As<IApiPortService>()
.WithParameter(TypedParameter.From(DefaultEndpoint))
.SingleInstance();
builder.RegisterType<ApiPortClient>()
.AsSelf()
.SingleInstance();
builder.Register(_ => OptionsModel.Load())
.As<OptionsModel>()
.OnRelease(m => m.Save())
.SingleInstance();
builder.RegisterType<TargetMapper>()
.As<ITargetMapper>()
.OnActivated(h => h.Instance.LoadFromConfig())
.InstancePerLifetimeScope();
builder.RegisterType<WindowsFileSystem>()
.As<IFileSystem>()
.SingleInstance();
// Register output services
builder.RegisterType<ReportGenerator>()
.As<IReportGenerator>()
.SingleInstance();
builder.RegisterType<OutputWindowWriter>()
.AsSelf()
.As<IOutputWindowWriter>()
.As<TextWriter>()
.SingleInstance();
builder.RegisterType<StatusBarProgressReporter>()
.As<IProgressReporter>()
.SingleInstance();
builder.RegisterType<ReportFileWriter>()
.As<IFileWriter>()
.SingleInstance();
builder.Register(GetOutputViewModel)
.As<OutputViewModel>()
.SingleInstance();
// Register menu handlers
builder.RegisterType<AnalyzeMenu>()
.AsSelf()
.SingleInstance();
builder.RegisterType<FileListAnalyzer>()
.AsSelf()
.InstancePerLifetimeScope();
builder.RegisterType<ProjectAnalyzer>()
.AsSelf()
.InstancePerLifetimeScope();
// Register option pane services
builder.RegisterType<OptionsPageControl>()
.AsSelf()
.InstancePerLifetimeScope();
builder.RegisterType<OptionsViewModel>()
.AsSelf()
.InstancePerLifetimeScope();
// Metadata manipulation registrations
builder.RegisterType<CciDependencyFinder>()
.As<IDependencyFinder>()
.InstancePerLifetimeScope();
builder.RegisterType<CciSourceLineMapper>()
.As<ISourceLineMapper>()
.InstancePerLifetimeScope();
// VS type registration
// Registers all of the Visual Studio Package components.
await RegisterVisualStudioComponentsAsync(builder, serviceProvider);
return new ServiceProvider(builder.Build());
}