/// <summary> /// register IMongoDBContext if not exists /// </summary> /// <param name="dbContext"></param> public static void RegisterMongoDBContext(IMongoDBContext dbContext) { if (Contexts.Exists(c => c.Code == dbContext.GetType().FullName)) { return; } IRegistrationContext context = new RegistrationContext(); context.RegisterDBContext(dbContext); context.GetAllTypes().ForEach(delegate(Type t) { Contexts.ForEach(delegate(IRegistrationContext con) { if (con.GetAllTypes().Exists(_t => _t.FullName == t.FullName)) { throw new Exception(string.Format("Conflicted type {0} between {1} and {2}", t.FullName, con.Code, context.Code)); } }); }); Contexts.Add(context); }
public void RegisterDBContext(IMongoDBContext context) { _dbContextType = context.GetType(); this._configuration = context.BuildConfiguration(); context.OnRegisterModel(_typeResolver); }