Example #1
0
        /// <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();
        }
Example #2
0
        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();
        }
Example #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();
        }
Example #4
0
        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());
        }
Example #5
0
 protected AbstractManager()
 {
     AutofacRegistrations.RegisterDaoFactory();
     Scope      = AutofacRegistrations.Container.BeginLifetimeScope();
     DaoFactory = Scope.Resolve <IDaoFactory>();
 }