/// <summary>
        ///     Initialize the AutoMapper mappings for the solution.
        ///     http://automapper.codeplex.com/
        /// </summary>
        public static void CreateAutoMapperMaps()
        {
            AutofacRegistrations.RegisterDaoFactory();
            ILifetimeScope scope      = AutofacRegistrations.Container.BeginLifetimeScope();
            var            daoFactory = scope.Resolve <IDaoFactory>();

            Mapper.CreateMap <Error, ErrorDto>()
            .ReverseMap();

            IPlaylistDao playlistDao = daoFactory.GetPlaylistDao();
            IUserDao     userDao     = daoFactory.GetUserDao();

            Mapper.CreateMap <Playlist, PlaylistDto>();
            Mapper.CreateMap <PlaylistDto, Playlist>()
            .ForMember(playlist => playlist.User, opt => opt.MapFrom(playlistDto => userDao.Get(playlistDto.UserId)));

            Mapper.CreateMap <PlaylistItem, PlaylistItemDto>();
            Mapper.CreateMap <PlaylistItemDto, PlaylistItem>()
            .ForMember(playlistItem => playlistItem.Playlist, opt => opt.MapFrom(playlistItemDto => playlistDao.Get(playlistItemDto.PlaylistId)));

            Mapper.CreateMap <ShareCode, ShareCodeDto>().ReverseMap();

            Mapper.CreateMap <User, UserDto>().ReverseMap();
            Mapper.CreateMap <Video, VideoDto>().ReverseMap();

            Mapper.AssertConfigurationIsValid();
        }
        public void TestFixtureSetUp()
        {
            //  Initialize Autofac for dependency injection.
            AutofacRegistrations.RegisterDaoFactory();
            Scope      = AutofacRegistrations.Container.BeginLifetimeScope();
            DaoFactory = Scope.Resolve <IDaoFactory>();

            //  Initialize AutoMapper with Streamus' server mappings.
            Streamus.InitializeApplication();
        }
Exemple #3
0
        protected void Application_Start()
        {
            JsonMediaTypeFormatter json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            json.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.All;

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //  Register your new model binder
            ModelBinders.Binders.DefaultBinder = new JsonEmptyStringNotNullModelBinder();

            AutofacRegistrations.RegisterDaoFactory();

            CreateAutoMapperMaps();
        }
        public static void InitializeApplication()
        {
            //HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

            JsonMediaTypeFormatter json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            json.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.All;

            //  Register your new model binder
            ModelBinders.Binders.DefaultBinder = new JsonEmptyStringNotNullModelBinder();

            AutofacRegistrations.RegisterDaoFactory();

            CreateAutoMapperMaps();

            //  TODO: It would be nice to use ServiceStack JSON deserializing as it is faster than the default, but I can't get it
            //  to properly deserialize child entities in the JSON object.
            //Remove and JsonValueProviderFactory and add JsonServiceStackValueProviderFactory
            //ValueProviderFactories.Factories.Remove(ValueProviderFactories.Factories.OfType<JsonValueProviderFactory>().FirstOrDefault());
            //ValueProviderFactories.Factories.Add(new JsonServiceStackValueProviderFactory());
        }
Exemple #5
0
 protected AbstractManager()
 {
     AutofacRegistrations.RegisterDaoFactory();
     Scope      = AutofacRegistrations.Container.BeginLifetimeScope();
     DaoFactory = Scope.Resolve <IDaoFactory>();
 }