/// <summary> /// 启动本地服务 /// </summary> /// <typeparam name="domainType"></typeparam> /// <param name="workPath"></param> /// <param name="domains"></param> /// <param name="log"></param> /// <returns></returns> private RegisterState start <domainType>(string workPath, Domain[] domains, ILog log) where domainType : HttpDomainServer.Server { RegisterState state = RegisterState.StartError; #if NoAutoCSer throw new Exception(); #else TcpInternalServer tcpServer = new TcpInternalServer(null, null, this, null, log); base.SetTcpServer(tcpServer); Assembly assembly = typeof(domainType).Assembly; LocalDomainServer = AutoCSer.Emit.Constructor <domainType> .New(); LocalDomainServer.LoadCheckPath = getLoadCheckPath(new DirectoryInfo(workPath ?? AutoCSer.PubPath.ApplicationPath)).FullName; if (LocalDomainServer.Start(this, domains, null)) { if ((state = start(domains)) == RegisterState.Success) { AutoCSer.Log.Pub.Log.Add(AutoCSer.Log.LogType.Info, @"domain success " + domains.joinString(@" ", domain => domain.Host.Host + ":" + domain.Host.Port.toString()), new System.Diagnostics.StackFrame(), false); return(RegisterState.Success); } } #endif return(state); }
/// <summary> /// 启动本地服务 /// </summary> /// <typeparam name="domainType"></typeparam> /// <param name="workPath"></param> /// <param name="domains"></param> /// <param name="log"></param> /// <returns></returns> private RegisterState start <domainType>(string workPath, Domain[] domains, ILog log) where domainType : HttpDomainServer.Server { RegisterState state = RegisterState.StartError; #if NoAutoCSer throw new Exception(); #else TcpInternalServer tcpServer = new TcpInternalServer(null, null, this, 0, null, log); base.SetTcpServer(tcpServer); Assembly assembly = typeof(domainType).Assembly; LocalDomainServer = AutoCSer.Metadata.DefaultConstructor <domainType> .Constructor(); LocalDomainServer.LoadCheckPath = getLoadCheckPath(new DirectoryInfo(workPath ?? AutoCSer.Config.ApplicationPath)).FullName; if (LocalDomainServer.Start(this, domains, null)) { if ((state = start(domains)) == RegisterState.Success) { AutoCSer.LogHelper.Info(@"domain success " + domains.joinString(@" ", domain => domain.Host.Host + ":" + domain.Host.Port.toString()), LogLevel.Info | LogLevel.AutoCSer); return(RegisterState.Success); } } #endif return(state); }