public void Initialize(ISessionManager sessionManager) //, IPersistenceConfigurer persistenceConfigurer)
        {
            sessionManager.Init(this);
            this.sessionManager = sessionManager;

            currentConfiguration = new Configuration();
            currentConfiguration.Configure();

            var fc = FHN.Fluently.Configure(currentConfiguration)
                     //.Database(persistenceConfigurer)
                     //.Diagnostics(x=>x.OutputToConsole())
                     .Mappings(x => {
                foreach (var prov in  MappingProviders)
                {
                    foreach (var mapping in prov.FluentMappings)
                    {
                        x.FluentMappings.Add(mapping);
                    }
                }
                x.FluentMappings.Conventions.Add(MappingConventions.ToArray());
            });

            currentConfiguration = fc.BuildConfiguration();

            InitializeValidation();
            InitListeners();

            currentConfiguration.SetProperty("proxyfactory.factory_class", typeof(ProxyFactoryFactory).AssemblyQualifiedName);

            sessionFactory = currentConfiguration.BuildSessionFactory();
        }
Exemple #2
0
        public Configuration(Action <Configuration> config = null)
        {
            var rootTypePair = new TypePair(typeof(object), typeof(object));
            var rootMapping  = new TypeMapping(this, rootTypePair)
            {
                //for the root mapping set values aside from INHERIT for each option
                ReferenceBehavior  = ReferenceBehaviors.CREATE_NEW_INSTANCE,
                CollectionBehavior = CollectionBehaviors.RESET
            };

            _typeMappings = new TypeMappingInheritanceTree(rootMapping);

            this.Conventions = new MappingConventions(cfg =>
            {
                cfg.GetOrAdd <DefaultConvention>(conv =>
                {
                    conv.SourceMemberProvider.IgnoreProperties       = false;
                    conv.SourceMemberProvider.IgnoreFields           = true;
                    conv.SourceMemberProvider.IgnoreNonPublicMembers = true;
                    conv.SourceMemberProvider.IgnoreMethods          = true;

                    conv.TargetMemberProvider.IgnoreProperties       = false;
                    conv.TargetMemberProvider.IgnoreFields           = true;
                    conv.TargetMemberProvider.IgnoreNonPublicMembers = true;
                    conv.TargetMemberProvider.IgnoreMethods          = true;

                    conv.MatchingRules
                    .GetOrAdd <ExactNameMatching>(rule => rule.IgnoreCase = true)
                    .GetOrAdd <PrefixMatching>(rule => rule.IgnoreCase    = true)
                    .GetOrAdd <SuffixMatching>(rule => rule.IgnoreCase    = true);
                });
            });

            //Order is important: the first MapperExpressionBuilder able to handle a mapping is used.
            //Make sure to use a collection which preserve insertion order!
            this.Mappers = new List <IMappingExpressionBuilder>()
            {
                new StringToEnumMapper(this),
                new EnumMapper(this),
                new BuiltInTypeMapper(this),
                new NullableMapper(this),
                new ConvertMapper(this),
                new StructMapper(this),
                new ArrayMapper(this),
                new DictionaryMapper(this),
                new ReadOnlyCollectionMapper(this),
                new StackMapper(this),
                new QueueMapper(this),
                new LinkedListMapper(this),
                new CollectionMapper(this),
                new ReferenceMapper(this),
                new ReferenceToStructMapper(this),
            };

            config?.Invoke(this);
        }
//		IEnumerable<IMemberMetaData> metadata;

        public ConventionMapping(Type type, IEnumerable <Type> otherTypes, MappingConventions conventions)
        {
            this.type        = type;
            this.otherTypes  = otherTypes;
            this.conventions = conventions;
//			this.metadata = conventions.MetaDataBuilder.GetMetaData(type);

//			tableName = conventions.TableName.GetTableName(type);
            tableName    = conventions.TableNameSelector(type);
            innerMapping = conventions.MappingCreator(type);

            innerMapping.CustomProperties[Constants.TableName] = tableName;

            LoadPropertyMappings();
        }
 public FluentAutoId(MappingConventions conventions)
 {
     this.conventions = conventions;
 }
Exemple #5
0
 public MappingContext(IModelInspector modelInspector, MappingConventions conventions)
 {
     ModelInspector = modelInspector;
     Conventions = conventions;
 }
 public FluentConventions(MappingConventions model)
 {
     this.Conventions = model;
 }
 public void ApplyConventions(ClassMapModel classMapModel)
 {
     this.conventions = classMapModel.Conventions;
     this.Visit(classMapModel);
 }