当前位置: 首页>>代码示例>>C#>>正文


C# IServiceCollection.AddSmartUser方法代码示例

本文整理汇总了C#中IServiceCollection.AddSmartUser方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddSmartUser方法的具体用法?C# IServiceCollection.AddSmartUser怎么用?C# IServiceCollection.AddSmartUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceCollection的用法示例。


在下文中一共展示了IServiceCollection.AddSmartUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            var appEnv = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();

            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<EMContext>(x => x.UseSqlite("Data source=" + appEnv.ApplicationBasePath + "/Database/EMWeb.db"));

            services.AddIdentity<User, IdentityRole<long>>(x=> {
                x.Password.RequireDigit = false;
                x.Password.RequiredLength = 0;
                x.Password.RequireLowercase = false;
                x.Password.RequireNonLetterOrDigit = false;
                x.Password.RequireUppercase = false;
                x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<EMContext,long>()
                .AddDefaultTokenProviders();
            services.AddFileUpload()
                .AddEntityFrameworkStorage<EMContext>();
            services.AddMvc();
            services.AddSmartUser<User,long>();

            
        }
开发者ID:Cream2015,项目名称:EMWeb,代码行数:25,代码来源:Startup.cs

示例2: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            #region Adding Entity Framework v7
            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<ChinaTowerContext>(x => x.UseSqlite($"Data source={PlatformServices.Default.Application.ApplicationBasePath}/Database/chinatower.db"));
            #endregion

            #region Adding Identity v3
            services.AddIdentity<User, IdentityRole>(x => 
            {
                x.Password.RequireDigit = false;
                x.Password.RequiredLength = 0;
                x.Password.RequireLowercase = false;
                x.Password.RequireNonLetterOrDigit = false;
                x.Password.RequireUppercase = false;
                x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<ChinaTowerContext>()
                .AddDefaultTokenProviders();
            #endregion

            #region Adding Others
            services.AddConfiguration();
            services.AddMvc();
            services.AddSmartCookies();
            services.AddSmartUser<User, string>();
            services.AddAesCrypto();
            services.AddSmtpEmailSender("smtp.ym.163.com", 25, "中国铁塔", "[email protected]", "[email protected]", "123456");
            services.AddWgsDis();
            #endregion
        }
开发者ID:CodeCombLLC,项目名称:ChinaTower,代码行数:32,代码来源:Startup.cs

示例3: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            // Add smart cookies
            services.AddSmartCookies();

            // Add entity framework and in-memory storage
            services.AddEntityFramework()
                .AddInMemoryDatabase()
                .AddDbContext<SampleContext>(x => x.UseInMemoryDatabase());

            // Add identity
            services.AddIdentity<Models.User, IdentityRole>(x =>
            {
                x.Password.RequiredLength = 0;
                x.Password.RequireDigit = false;
                x.Password.RequireLowercase = false;
                x.Password.RequireNonLetterOrDigit = false;
                x.Password.RequireUppercase = false;
                x.User.RequireUniqueEmail = false;
                x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<SampleContext>()
                .AddDefaultTokenProviders();

            // Add mvc with multi template engine and cookie based template provider
            services.AddMvc()
                .AddTemplate()
                .AddCookieTemplateProvider();

            services.AddSmartUser<User, string>();
        }
开发者ID:CodeComb,项目名称:Extensions,代码行数:31,代码来源:Startup.cs

示例4: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            var _serv = services.BuildServiceProvider();
            var appRoot = _serv.GetRequiredService<IApplicationEnvironment>().ApplicationBasePath;
            
            IConfiguration Configuration;
            services.AddConfiguration(out Configuration);

            if (Configuration["Data:DefaultConnection:Mode"] == "SQLite")
            {
                services.AddEntityFramework()
                    .AddDbContext<vNextChinaContext>(x => x.UseSqlite(Configuration["Data:DefaultConnection:ConnectionString"].Replace("{appRoot}", appRoot)))
                    .AddSqlite();
            }
            else if (Configuration["Data:DefaultConnection:Mode"] == "SqlServer")
            {
                services.AddEntityFramework()
                    .AddDbContext<vNextChinaContext>(x => x.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]))
                    .AddSqlServer();
            }
            else
            {
                services.AddEntityFramework()
                    .AddDbContext<vNextChinaContext>(x => x.UseInMemoryDatabase())
                    .AddInMemoryDatabase();
            }
            
            services.AddIdentity<User, IdentityRole<long>>(x => 
            {
                x.Password.RequireDigit = false;
                x.Password.RequiredLength = 0;
                x.Password.RequireLowercase = false;
                x.Password.RequireNonLetterOrDigit = false;
                x.Password.RequireUppercase = false;
                x.User.AllowedUserNameCharacters = null;
            })
                .AddEntityFrameworkStores<vNextChinaContext, long>()
                .AddDefaultTokenProviders();

            services.AddMvc();
            services.AddSmartUser<User, long>();
            services.AddSmartCookies();
            services.AddAntiXss();
            services.AddSmtpEmailSender("smtp.qq.com", 25, "vNext China", "[email protected]", "911574351", "XXX");
            services.AddAesCrypto();
            services.AddEFNodeProvider<vNextChinaContext>();
            services.AddSignalR();
        }
开发者ID:Jeffiy,项目名称:vnextcn.org,代码行数:48,代码来源:Startup.cs

示例5: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFramework()
                .AddDbContext<MOContext>(x => x.UseSqlite("Data source=mobileoperation.db"))
                .AddSqlite();

            services.AddIdentity<User, IdentityRole>()
                .AddEntityFrameworkStores<MOContext>()
                .AddDefaultTokenProviders();

            services.AddFileUpload()
                .AddEntityFrameworkStorage<MOContext>();

            services.AddMvc();
            services.AddSmartUser<User, string>();
            services.AddSmartCookies();
        }
开发者ID:CodeCombLLC,项目名称:MobileOperation,代码行数:17,代码来源:Startup.cs

示例6: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            var appEnv = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();

            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<ForumContext>(x => x.UseSqlServer("Server=localhost;uid=sa;password=123456;database=acforum;"));

            services.AddIdentity<User, IdentityRole>()
                .AddEntityFrameworkStores<ForumContext>()
                .AddDefaultTokenProviders();

            services.AddMvc();

            services.AddSmartUser<User, string>();

        }
开发者ID:AsiaCream,项目名称:ACForum,代码行数:17,代码来源:Startup.cs

示例7: ConfigureServices

        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            //获取应用环境服务
            var appEnv = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();

            //添加entity framework服务
            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<MemberContext>(x => x.UseSqlite("Date source=" + appEnv.ApplicationBasePath + "/member.db"));

            //添加identity服务
            services.AddIdentity<User, IdentityRole>()
                .AddEntityFrameworkStores<MemberContext>()
                .AddDefaultTokenProviders();
            //添加mvc服务
            services.AddMvc();
            services.AddSmartUser<User, string>();
        }
开发者ID:AsiaCream,项目名称:LibraryInformation-,代码行数:19,代码来源:Startup.cs


注:本文中的IServiceCollection.AddSmartUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。