如何在EC2实例中使用现有的IAM角色,而不是在我的CloudFormation模板中创建新角色?
例如,我在AWS Console中创建了一个角色,只想使用它.
我已经把头发拉了一段时间了,基本上我正在尝试实现一个通用的存储库工厂,调用如下:
var resposFactory = new RepositoryFactory<IRepository<Document>>();
Run Code Online (Sandbox Code Playgroud)
存储库工厂如下所示:
public class RepositoryFactory<T> : IRepositoryFactory<T>
{
public T GetRepository(Guid listGuid,
IEnumerable<FieldToEntityPropertyMapper> fieldMappings)
{
Assembly callingAssembly = Assembly.GetExecutingAssembly();
Type[] typesInThisAssembly = callingAssembly.GetTypes();
Type genericBase = typeof (T).GetGenericTypeDefinition();
Type tempType = (
from type in typesInThisAssembly
from intface in type.GetInterfaces()
where intface.IsGenericType
where intface.GetGenericTypeDefinition() == genericBase
where type.GetConstructor(Type.EmptyTypes) != null
select type)
.FirstOrDefault();
if (tempType != null)
{
Type newType = tempType.MakeGenericType(typeof(T));
ConstructorInfo[] c = newType.GetConstructors();
return (T)c[0].Invoke(new object[] { listGuid, fieldMappings });
}
} …Run Code Online (Sandbox Code Playgroud) 自从升级到实体框架6 rc 1后,当我的dbcontext初始化时,我开始收到以下错误:
System.TypeLoadException:无法从程序集'EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Data.Entity.Config.SingletonDependencyResolver`1'.
关于解决方案的任何想法?我找不到任何关于这件事!
编辑
我回到了beta 1,问题就消失了.潜在的RC 1错误......
我有一个特定的场景,其中聚合具有检查地址是否有效的行为。此验证是通过网站上的内联 ajax 表单验证在聚合上触发的。在聚合和网站之间是协调两者的应用程序服务。
就目前而言,我创建了一个本质上是空的聚合并设置了地址属性,以便可以完成检查。基于此,我将 true 或 false 返回到网站 (ASP.NET MVC)。在 DDD 的上下文中,这似乎不是正确的方法。
public bool IsAddressAvailable(string address)
{
var aggregate = new Aggregate
{
Address = address
};
return aggregate.IsAddressValid();
}
Run Code Online (Sandbox Code Playgroud)
我有哪些选择可以更好地使用 DDD?我正在考虑将其分离为域服务。任何意见,将不胜感激!