yangzhongke / netbookmaterials Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Line 8 in 04fdd51
下载代码后,因为电脑只安装了MySql,没安装SqlServer,所以就想用MySql做数据库,没想到遇到不少问题,现在总结一下,最后还有个问题:
configBuilder.AddDbConfiguration(() => new MySqlConnection(connStr), reloadOnChange: true, reloadInterval: TimeSpan.FromSeconds(5), tableName: "t_configs");
services.AddAllDbContexts()
里的//ctx.UseSqlServer(connStr); ctx.UseMySql(connStr, ServerVersion.AutoDetect(connStr));
//optionsBuilder.UseSqlServer(connStr); optionsBuilder.UseMySql(connStr, ServerVersion.AutoDetect(connStr));
builder.Services.AddAuthentication();
是不是多余的,因为下面有builder.Services.AddJWTAuthentication(jwtOpt);
了,认证服务重复了?我有两个微服务A和B,A是生产者也是自己的消费者,B是消费者,当我先启动B再启动A时,A发出的事件A自己不能监听到,B可以监听到;当我先启动A再启动B时,A自己发出的事件A自己可以监听到,B不能监听到
当我用这个方法存取字符串时它自动给我加了" ,看了源码是使用了System.Text.Json.JsonSerializer.Serialize方法导致的
上传音频保存到backupStorage有问题,保存的数据大小为0,需要在前面将position=0。
今天学习该项目的时候发现,实体添加了领域事件,然后并没有自动触发该事件。
调试过程中发现Zack.DomainCommons/Models/BaseEntity.cs 里面的 private List domainEvents = new();确实能够添加成功,
但是在YouZack-VNext/Zack.Infrastructure/EFCore/MediatorExtensions.cs中的 :
var domainEvents = domainEntities
.SelectMany(x => x.Entity.GetDomainEvents())
.ToList();
里拿不到值。
经过测试,在private List domainEvents = new()上加了个static拿到值了。
杨老师,我把builder.ConfigureExtraServices()和 services.RunModuleInitializers(assemblies);这两个方法,都改造成可以根据外部传入的不同的接口,实现DI的自动注入,每个项目在创建ModuleInitializer实现类基础上,也可以根据传入外部参数的接口类型集合,实现框架的自动注入。下面是我实现的代码,我现在不清楚这样实现有没有性能上的损失,这样改造不知道是否合适?
builder.ConfigureExtraServices(new InitializerOptions
{
EventBusQueueName = "IdentityService.WebAPI",
LogFilePath = "D:/temp/IdentityService.log"
}, options =>
{
options.Add(typeof(IServiceSupport));
});
//获取所有的类库
var assemblies = ReflectionHelper.GetAllReferencedAssemblies();
//调整为可以根据前端传递需要注入的接口集合
services.RunModuleInitializers(assemblies, options);
//
//liuyongfei 2023年1月10日15:14:10 后续添加可以根据不同类型接口实现DI自动注入
if (option != null)
{
var iocOption = new IocOption();
option(iocOption);//客户端类型注入
var definedTypes = assemblies.SelectMany(y => y.DefinedTypes).ToList();
foreach (var type in iocOption.Types)
{
var allTypes = definedTypes.Where(t => type.GetTypeInfo().IsAssignableFrom(t.AsType()));
var abstractTypes = allTypes.Where(t => t.IsInterface || t.IsAbstract);
var implTypes = allTypes.Where(t => t.IsInterface == false && t.IsAbstract == false).ToList();
foreach (var abstractType in abstractTypes)
{
if (abstractTypes.Count() > 1
&& abstractType.AssemblyQualifiedName == type.AssemblyQualifiedName)
{
continue;
}
var _implTypes = implTypes.Where(t => t.ImplementedInterfaces.Any(impl => impl.AssemblyQualifiedName == abstractType.AssemblyQualifiedName)
|| t.BaseType?.AssemblyQualifiedName == abstractType.AssemblyQualifiedName);
foreach (var implClass in _implTypes)
{
if (iocOption.ExceptTypes.Count > 0)
{
if (iocOption.ExceptTypes.Where(
t => t.AssemblyQualifiedName == abstractType.AssemblyQualifiedName
|| t.AssemblyQualifiedName == implClass.AssemblyQualifiedName).Any())
{
continue;
}
}
//配置ScopedDI
services.AddScoped(abstractType, implClass);
}
}
}
}
return services;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.