public void SetTypeMappers(MappingEngineCollection coll)
 {
     foreach (var binder in coll.Binders)
     {
         TypeMappers.Add(binder);
     }
 }
 public void SetTypeMappers(MappingEngineCollection coll)
 {
     foreach (var binder in coll.Binders)
     {
         TypeMappers.Add(binder);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public FakeFrameworkContext()
        {
            var fakeMapperList = new List <Lazy <AbstractMappingEngine, TypeMapperMetadata> >();

            TypeMappers      = new MappingEngineCollection(fakeMapperList);
            CurrentLanguage  = Thread.CurrentThread.CurrentCulture;
            TextManager      = LocalizationConfig.SetupDefault();
            ScopedFinalizer  = new NestedLifetimeFinalizer();
            TaskManager      = new ApplicationTaskManager(Enumerable.Empty <Lazy <AbstractTask, TaskMetadata> >());
            ApplicationCache = new HttpRuntimeApplicationCache();
            ScopedCache      = new ThreadStaticScopedCache();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultFrameworkContext"/> class.
 /// </summary>
 /// <param name="textManager">The text manager.</param>
 /// <param name="typeMappers">The type mappers.</param>
 /// <param name="scopedCache">The scoped cache.</param>
 /// <param name="applicationCache">The application cache</param>
 /// <param name="finalizer"></param>
 /// <param name="taskMgr"></param>
 /// <remarks></remarks>
 public DefaultFrameworkContext(
     TextManager textManager,
     MappingEngineCollection typeMappers,
     AbstractScopedCache scopedCache,
     AbstractApplicationCache applicationCache,
     AbstractFinalizer finalizer,
     ApplicationTaskManager taskMgr)
     : this(scopedCache, applicationCache, finalizer)
 {
     TextManager = textManager;
     TypeMappers = typeMappers;
     TaskManager = taskMgr;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public FakeFrameworkContext(ISerializer serializer = null)
 {
     serializer = serializer ?? new ServiceStackSerialiser();
     var fakeMapperList = new List<Lazy<AbstractMappingEngine, TypeMapperMetadata>>();
     TypeMappers = new MappingEngineCollection(fakeMapperList);
     CurrentLanguage = Thread.CurrentThread.CurrentCulture;
     TextManager = LocalizationConfig.SetupDefault();
     ScopedFinalizer = new NestedLifetimeFinalizer();
     TaskManager = new ApplicationTaskManager(Enumerable.Empty<Lazy<AbstractTask, TaskMetadata>>());
     ApplicationCache = new HttpRuntimeApplicationCache();
     ScopedCache = new DictionaryScopedCache();
     Caches = new DefaultFrameworkCaches(new DictionaryCacheProvider(), new RuntimeCacheProvider());
     Serialization = new SerializationService(serializer);
 }
        public void MapAndMerge(AbstractEntity entity, MappingEngineCollection mappers)
        {
            using (DisposableTimer.TraceDuration <NhSessionHelper>("Start MapAndMerge for entity " + entity.Id, "End MapAndMerge"))
                using (NhProfilerLogging.Start(NhSession, "MapAndMerge",
                                               new OdbcParameter("entity", entity)))
                {
                    var rdbmsEntity = mappers.MapToIntent <IReferenceByGuid>(entity);

                    // Track ID generation on the Rdbms object so that it can be pinged to the AbstractEntity upon Save/Update commit
                    rdbmsEntity = NhSession.Merge(rdbmsEntity) as IReferenceByGuid;

                    //InnerDataContext.NhibernateSession.SaveOrUpdate(rdbmsEntity);
                    mappers.Map(rdbmsEntity, entity, rdbmsEntity.GetType(), entity.GetType());
                }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public FakeFrameworkContext(ISerializer serializer = null)
        {
            serializer = serializer ?? new ServiceStackSerialiser();
            var fakeMapperList = new List <Lazy <AbstractMappingEngine, TypeMapperMetadata> >();

            TypeMappers      = new MappingEngineCollection(fakeMapperList);
            CurrentLanguage  = Thread.CurrentThread.CurrentCulture;
            TextManager      = LocalizationConfig.SetupDefault();
            ScopedFinalizer  = new NestedLifetimeFinalizer();
            TaskManager      = new ApplicationTaskManager(Enumerable.Empty <Lazy <AbstractTask, TaskMetadata> >());
            ApplicationCache = new HttpRuntimeApplicationCache();
            ScopedCache      = new DictionaryScopedCache();
            Caches           = new DefaultFrameworkCaches(new DictionaryCacheProvider(), new RuntimeCacheProvider());
            Serialization    = new SerializationService(serializer);
        }
        public void MapAndMerge <T>(Revision <T> entity, MappingEngineCollection mappers) where T : class, IVersionableEntity
        {
            HiveId hiveId   = entity.MetaData != null ? entity.MetaData.Id : HiveId.Empty;
            HiveId entityId = entity.Item != null ? entity.Item.Id : HiveId.Empty;

            using (DisposableTimer.TraceDuration <NhSessionHelper>("Start MapAndMerge for revision " + hiveId + " entity " + entityId, "End MapAndMerge"))
                using (NhProfilerLogging.Start(NhSession, "MapAndMerge<T> (Revision<T>)",
                                               new OdbcParameter("entity", entity)))
                {
                    var rdbmsEntity = mappers.MapToIntent <IReferenceByGuid>(entity);

                    // Track ID generation on the Rdbms object so that it can be pinged to the AbstractEntity upon Save/Update commit
                    rdbmsEntity = NhSession.Merge(rdbmsEntity) as IReferenceByGuid;

                    // 16th Jan 12 (APN) NH is not flushing if the above merged entity is queried before the transaction is committed, despite
                    // the flushmode being Auto. So, explicit call to Flush here pending a bugfix/ better solution
                    NhSession.Flush();

                    //InnerDataContext.NhibernateSession.SaveOrUpdate(rdbmsEntity);
                    mappers.Map(rdbmsEntity, entity, rdbmsEntity.GetType(), entity.GetType());
                }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultFrameworkContext"/> class.
 /// </summary>
 /// <param name="textManager">The text manager.</param>
 /// <param name="typeMappers">The type mappers.</param>
 /// <param name="scopedCache">The scoped cache.</param>
 /// <param name="applicationCache">The application cache</param>
 /// <param name="finalizer">The finalizer.</param>
 /// <param name="taskMgr">The task manager.</param>
 /// <param name="caches">The lifetime-managed cache providers.</param>
 public DefaultFrameworkContext(
     TextManager textManager, 
     MappingEngineCollection typeMappers, 
     AbstractScopedCache scopedCache,
     AbstractApplicationCache applicationCache,
     AbstractFinalizer finalizer,
     ApplicationTaskManager taskMgr,
     IFrameworkCaches caches,
     AbstractSerializationService serialization)
     : this(scopedCache, applicationCache, finalizer, caches, serialization)
 {
     TextManager = textManager;
     TypeMappers = typeMappers;
     TaskManager = taskMgr;
 }
 public FakeFrameworkContext(MappingEngineCollection typeMappers) : this()
 {
     TypeMappers = typeMappers;
 }
 public FakeFrameworkContext(MappingEngineCollection typeMappers) : this()
 {
     TypeMappers = typeMappers;
 }