private void ActiveRecordStarter_ModelsCreated(ActiveRecordModelCollection models, IConfigurationSource source) { //var model = new ActiveRecordModel(typeof(AnotherEntity)); //Configuration cfg; //cfg.ClassMappings. //model. //models.Add(model); }
/// <summary> /// Handles the models creation event and pre-process the models /// </summary> public static void ModelsCreated(ActiveRecordModelCollection models, IConfigurationSource source) { foreach (ActiveRecordModel model in models) { if (!IsCacheable(model.Type)) { model.ActiveRecordAtt.Cache = CacheEnum.ReadWrite; } foreach (HasManyModel hasManyModel in model.HasMany) { if (!IsCacheable(hasManyModel.HasManyAtt.MapType)) continue; hasManyModel.HasManyAtt.Cache = CacheEnum.ReadWrite; } } }
/// <summary> /// Initializes a new instance of the <see cref="GraphConnectorVisitor"/> class. /// </summary> /// <param name="arCollection">The ar collection.</param> public GraphConnectorVisitor(ActiveRecordModelCollection arCollection) { this.arCollection = arCollection; }
/// <summary> /// Initializes a new instance of the <see cref="SemanticVerifierVisitor"/> class. /// </summary> /// <param name="arCollection">The ar collection.</param> public SemanticVerifierVisitor(ActiveRecordModelCollection arCollection) { this.arCollection = arCollection; }
private static void AddXmlToNHibernateCfg(ISessionFactoryHolder holder, ActiveRecordModelCollection models) { XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor(); AssemblyXmlGenerator assemblyXmlGenerator = new AssemblyXmlGenerator(); ISet assembliesGeneratedXmlFor = new HashedSet(); foreach(ActiveRecordModel model in models) { Configuration config = holder.GetConfiguration(holder.GetRootType(model.Type)); if (config == null) { throw new ActiveRecordException( string.Format( "Could not find configuration for {0} or its root type {1} this is usually an indication that the configuration has not been setup correctly.", model.Type, holder.GetRootType(model.Type))); } if (!model.IsNestedType && !model.IsDiscriminatorSubClass && !model.IsJoinedSubClass) { xmlVisitor.Reset(); xmlVisitor.CreateXml(model); String xml = xmlVisitor.Xml; if (xml != String.Empty) { AddXmlString(config, xml, model); } } } }
private static void VerifySchema(ActiveRecordModelCollection models) { foreach(ActiveRecordModel model in models) { if (!model.Type.IsAbstract) { try { ActiveRecordMediator.FindAll(model.Type, Expression.Sql("1=0")); } catch(Exception ex) { throw new ActiveRecordException("Error verifying the schema for model " + model.Type.Name, ex); } } } }
private static void AddXmlToNHibernateFromAssmebliesAttributes(ISessionFactoryHolder holder, ActiveRecordModelCollection models) { Iesi.Collections.Generic.ISet<Assembly> assembliesGeneratedXmlFor = new HashedSet<Assembly>(); AssemblyXmlGenerator assemblyXmlGenerator = new AssemblyXmlGenerator(); foreach (ActiveRecordModel model in models) { if (assembliesGeneratedXmlFor.Contains(model.Type.Assembly)) continue; assembliesGeneratedXmlFor.Add(model.Type.Assembly); Configuration config = holder.GetConfiguration(holder.GetRootType(model.Type)); string[] configurations = assemblyXmlGenerator.CreateXmlConfigurations(model.Type.Assembly); foreach (string xml in configurations) { if (xml != string.Empty) { config.AddXmlString(xml); } } } foreach (Assembly assembly in registeredAssemblies) { if (assembliesGeneratedXmlFor.Contains(assembly)) continue; assembliesGeneratedXmlFor.Add(assembly); Configuration config = holder.GetConfiguration(holder.GetRootType(typeof(ActiveRecordBase))); string[] configurations = assemblyXmlGenerator.CreateXmlConfigurations(assembly); foreach (string xml in configurations) { if (xml != string.Empty) { config.AddXmlString(xml); } } } }
/// <summary> /// Initializes a new instance of the <see cref="SemanticVerifierVisitor"/> class. /// </summary> /// <param name="arCollection">The ar collection.</param> public SemanticVerifierVisitor(ActiveRecordModelCollection arCollection) { this.arCollection = arCollection; }