本文整理汇总了C#中IServiceCollection.AddApplicationInsightsTelemetry方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddApplicationInsightsTelemetry方法的具体用法?C# IServiceCollection.AddApplicationInsightsTelemetry怎么用?C# IServiceCollection.AddApplicationInsightsTelemetry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceCollection
的用法示例。
在下文中一共展示了IServiceCollection.AddApplicationInsightsTelemetry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddUserStore<MyUserStore>()
.AddUserManager<MyUserManager>()
.AddRoleManager<MyRoleManager>()
.AddRoleStore<MyRoleStore>()
//.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddScoped<SignInManager<ApplicationUser>, MySignInManager>();
services.AddMvc();
services.AddCaching();
services.AddSession(options => {
options.IdleTimeout = TimeSpan.FromHours(23);
});
// Add application services.
//services.AddTransient<IEmailSender, AuthMessageSender>();
//services.AddTransient<ISmsSender, AuthMessageSender>();
}
示例2: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
//Swagger additons
services.AddMvcCore()
.AddApiExplorer();
services.AddSwaggerGen();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<BookServiceContext>(options =>
options.UseSqlServer(Configuration["ConnectionString"]));
//options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=BookServiceContext-70e8c6ed-94f8-4d84-97df-d0729ea62482;Trusted_Connection=True;MultipleActiveResultSets=true"));
}
示例3: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
// Configure swagger. For more details see e.g.
// http://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/
services.AddSwaggerGen();
services.ConfigureSwaggerDocument(options => options.SingleApiVersion(
new Info { Version = "v1", Title = "Demo" }));
// Use the new configuration model here. Note the use of
// different configuration sources (json, env. variables,
// middleware-specific configuration).
services.AddOptions();
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.AddApplicationInsightsSettings(developerMode: true);
var configuration = builder.Build();
// Publish options read from configuration file. With that,
// controllers can use ASP.NET DI to get options (see
// BooksController).
services.Configure<BooksDemoDataOptions>(
configuration.GetSection("booksDemoDataOptions"));
// Add AI configuration
services.AddApplicationInsightsTelemetry(configuration);
// Publish singleton for name generator
services.AddSingleton(typeof(INameGenerator), typeof(NameGenerator));
// Configure middlewares (CORS and MVC)
services.AddCors();
services.AddMvc();
}
示例4: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
// Create the Autofac container builder.
var builder = new ContainerBuilder();
// Add any Autofac modules or registrations.
builder.RegisterModule(new ServiceModule());
// Populate the services.
builder.Populate(services);
// Build the container.
var container = builder.Build();
// Resolve and return the service provider.
return container.Resolve<IServiceProvider>();
}
示例5: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add Application Insights data collection services to the services container.
services.AddApplicationInsightsTelemetry(Configuration);
// Add Entity Framework services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>(options => {
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireNonLetterOrDigit = false;
}).AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.Configure<IdentityDbContextOptions>(options =>
{
options.DefaultAdminUserName = Configuration["DefaultAdminUsername"];
options.DefaultAdminPassword = Configuration["DefaultAdminPassword"];
options.Roles = Configuration["Roles:Global"];
options.AdministratorRole = Configuration["Roles:Administrator"];
});
// Add MVC services to the services container.
services.AddMvc();
RegisterServices(services);
}
示例6: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:TJCMVCOnlyContext:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<TJCMVCOnlyContext>(options =>
options.UseSqlServer(Configuration["Data:TJCMVCOnlyContext:ConnectionString"]));
}
示例7: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddMvc();
services.AddSwaggerGen();
var filePath = Environment.CurrentDirectory.Split(new[] { "src" }, StringSplitOptions.None)[0] + Configuration["Documentation:SwaggerDocXml"];
services.ConfigureSwaggerDocument(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "Todo API",
Description = "A sample api",
TermsOfService = "None"
});
options.OperationFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlActionComments(filePath));
});
services.ConfigureSwaggerSchema(options =>
{
options.DescribeAllEnumsAsStrings = true;
options.ModelFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlTypeComments(filePath));
});
services.AddSingleton<ITodoRepository, TodoRepository>();
}
示例8: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddAuthorization();
services.AddOptions();
services.Configure<ConnectionOptions>(Configuration);
services.AddMvc(config =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
services.AddCors();
services.AddSwaggerGen();
services.AddRepositoryRegistrations();
}
示例9: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
// Inject services to application.
var mvcBuilder = services.AddMvc();
/*mvcBuilder.AddMvcOptions(option =>
{
option.OutputFormatters.OfType<JsonOutputFormatter>()
.First()
.SerializerSettings
.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
*/
// Create the Autofac container builder.
var builder = new ContainerBuilder();
// Add any Autofac modules or registrations.
builder.RegisterModule(new BusinessModule());
builder.RegisterModule(new SharedModule());
// Populate the services.
builder.Populate(services);
// Build the container.
var container = builder.Build();
// Resolve and return the service provider.
return container.Resolve<IServiceProvider>();
}
示例10: ConfigureServices
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry(Configuration);
// Add MVC services to the services container.
services.AddMvc();
}
示例11: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ChinookContext>(options => options.UseSqlServer(Configuration["Data:ChinookConnection:ConnectionString"]));
// Repositories
services.AddScoped<IAlbumRepository, AlbumRepository>();
services.AddScoped<IArtistRepository, ArtistRepository>();
services.AddScoped<ICustomerRepository, CustomerRepository>();
services.AddScoped<IEmployeeRepository, EmployeeRepository>();
services.AddScoped<IGenreRepository, GenreRepository>();
services.AddScoped<IInvoiceLineRepository, InvoiceLineRepository>();
services.AddScoped<IInvoiceRepository, InvoiceRepository>();
services.AddScoped<IMediaTypeRepository, MediaTypeRepository>();
services.AddScoped<IPlaylistTrackRepository, PlaylistTrackRepository>();
services.AddScoped<IPlaylistRepository, PlaylistRepository>();
services.AddScoped<ITrackRepository, TrackRepository>();
services.AddMvc()
.AddJsonOptions(options =>
{
options.SerializerSettings.ReferenceLoopHandling =
Newtonsoft.Json.ReferenceLoopHandling.Ignore;
options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
options.SerializerSettings.ContractResolver =
new CamelCasePropertyNamesContractResolver();
});
}
示例12: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
var connection = @"Server=DESKTOP-2N2TC81;Database=NeedleWork2016;Trusted_Connection=True;";
//var connection = @"Data Source=10.10.200.62;Initial Catalog=NeedleWork2016;Persist Security Info=True;User ID=needlework2016;Password=Qwerty1!";
services.AddEntityFramework()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connection));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddMvc();
services.AddMvc(options =>
{
options.Filters.Add(new ConvertToPdfFilterAttribute());
options.Filters.Add(new CultureAttribute());
});
}
示例13: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry(Configuration);
if (_isDevEnvironment)
{
services.AddHaufwerk(new HaufwerkOptions("Haufwerk", "http://localhost:5000")
{
LogLocalRequests = true
});
}
else
{
services.AddHaufwerk(new HaufwerkOptions("Haufwerk", "https://haufwerk.sachsenhofer.com")
{
LogLocalRequests = true
});
}
services.AddMvc();
services.AddDbContext<Db>(options =>
{
options.UseSqlServer(Configuration["Database:ConnectionString"]);
});
}
示例14: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddSingleton(settings => new Settings
{
RecipeAppId = Configuration["Keys:Recipe:AppId"],
RecipeAppKey = Configuration["Keys:Recipe:AppKey"]
});
}
示例15: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR(options =>
{
options.Hubs.EnableDetailedErrors = true;
options.Hubs.EnableJavaScriptProxies = true;
});
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
}