locked
ObjectFactory.cs not found RRS feed

  • Question

  • User459659623 posted

    I am working with an I am working with an ecommerce project where i am following Fohjin's cqrs architecture and for resolve dependency I am using structuremap Ioc container. When run my application during resolve the dependency structuremap shows me following message ObjectFactory.cs not found. Below is my Ioc class definitionecommerce project where i am following Fohjin's cqrs architecture and for resolve dependency I am using structuremap Ioc container. When run my application during resolve the dependency structuremap shows me following message ObjectFactory.cs not found. Below is my Ioc class definition

    public static class IoC {
            public static IContainer Initialize() {
                ObjectFactory.Initialize(x =>
                            {
                                x.Scan(scan =>
                                        {
                                            scan.TheCallingAssembly();
                                            scan.WithDefaultConventions();
                                        });
                //                x.For<IExample>().Use<Example>();
    
    
                                x.For<IBus>().Use<DirectBus>();
                                x.For<IRouteMessages>().Use<MessageRouter>();
                                x.For<IDomainEventStorage<IDomainEvent>>().Use<DomainEventStorage<IDomainEvent>>();
                                x.For<IIdentityMap<IDomainEvent>>().Use<EventStoreIdentityMap<IDomainEvent>>();
                                x.For<IEventStoreUnitOfWork<IDomainEvent>>().Use<EventStoreUnitOfWork<IDomainEvent>>();
                                x.For<IDomainRepository<IDomainEvent>>().Use<DomainRepository<IDomainEvent>>();
                                x.For<ICacheStorage>().Use<HttpContextCacheAdapter>();
                                x.For<IDataContextFactory>().Use<DataContextFactory>();
                                x.For<IReportingUnitOfWork>().Use<ReportingUnitOfWork>();
    
    
                                //Repositories
                                x.For<IAuthorRepository>().Use<AuthorRepository>();
                                x.For<ICategoryRepository>().Use<CategoryRepository>();
                                x.For<IPublisherRepository>().Use<PublisherRepository>();
                                x.For<IBookRepository>().Use<BookRepository>();
                                x.For<IWishListRepository>().Use<WishListRepository>();
                                x.For<IReviewRepository>().Use<ReviewRepository>();
                                x.For<IUserLogRepository>().Use<UserLogRepository>();
    
                                //Services
                                x.For<IAuthorFacadeService>().Use<AuthorFacadeService>();
                                x.For<IBookCategoryFacadeService>().Use<BookCategoryFacadeService>();
                                x.For<IBookFacadeService>().Use<BookFacadeService>();
                                x.For<IMyLibraryFacadeService>().Use<MyLibraryFacadeService>();
                                x.For<IPublisherFacadeService>().Use<PublisherFacadeService>();
                                x.For<IUserFacadeService>().Use<UserFacadeService>();
                                x.For<IWishListFacadeService>().Use<WishListFacadeService>();
    
                            });
    
                RegisterCommandHandlersInMessageRouter.BootStrap();
                RegisterEventHandlersInMessageRouter.BootStrap();
                return ObjectFactory.Container;
            }
        }
    


    Finally when I try to save any data it shows me No route specified for message

    Below is given my MessageRouter and RegisterRouter class definition

    public class MessageRouter : IRouteMessages
        {
            private readonly IDictionary<Type, ICollection<Action<object>>> _routes;
    
            public MessageRouter()
            {
                _routes = new Dictionary<Type, ICollection<Action<object>>>();
            }
    
            public void Register<TMessage>(Action<TMessage> route) where TMessage : class
            {
                var routingKey = typeof(TMessage);
                ICollection<Action<object>> routes;
    
                if (!_routes.TryGetValue(routingKey, out routes))
                    _routes[routingKey] = routes = new LinkedList<Action<object>>();
    
                routes.Add(message => route(message as TMessage));
            }
    
            public void Route(object message)
            {
                ICollection<Action<object>> routes;
    
                if (!_routes.TryGetValue(message.GetType(), out routes))
                    throw new RouteNotRegisteredException(message.GetType());
    
                foreach (var route in routes)
                    route(message);
            }
        }

    Last three days I am struggling with this exception but yet not able to fix. Even I don't know where i make mistake.

    My entire code is available in https://drive.google.com/file/d/0B1rU7HOTfLweZjFuZlF3M0Z2M28/edit?usp=sharing

    Monday, April 14, 2014 3:34 AM

All replies