示例#1
0
        protected void Application_Start()
        {
            ServiceOptions = ServiceOptions.LoadServiceOptions();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);

            var builder = new ContainerBuilder();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            //configure the service
            if (ServiceOptions.UseEmbeddedService)
                ConfigureEmbeddedService(builder, ServiceOptions.ServiceLibraryPath + "\\Frictionless.WCF.Service.dll");
            else
                ConfigureWcfService(builder, ServiceOptions.ServiceUrl);

            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            Frictionless.WCF.Interface.IService1 service = container.Resolve<Frictionless.WCF.Interface.IService1>();
        }
示例#2
0
        public static ServiceOptions LoadServiceOptions()
        {
            ServiceOptions options = new ServiceOptions();

            bool embedService = false;
            bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["EmbedService"], out embedService);
            options.UseEmbeddedService = embedService;

            string servicePath = System.Configuration.ConfigurationManager.AppSettings["ServicePath"] ?? "";
            string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
            currentPath = currentPath.Replace("file:\\", "");
            string serviceDirectory = new DirectoryInfo(currentPath + "\\" + servicePath).FullName;
            options.ServiceLibraryPath = serviceDirectory;

            options.ServiceUrl = System.Configuration.ConfigurationManager.AppSettings["ServiceUrl"] ?? "";

            return options;
        }