public class BeforStart { /// <summary> /// 程式配置初始化 /// </summary> public static void EASConfig() { #region 系統日誌 ComponentInfo Log = new ComponentInfo(); Log.Name = "Logger"; Log.Type = "EAS.Services.TextLogger"; Log.Assembly = "EAS.MicroKernel"; Log.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Singleton; ComponentConfig.Components.Add(Log.Name, Log); #endregion #region 系統資源 ComponentInfo Component = new ComponentInfo(); Component.Name = "EAS.Explorer.Resource"; Component.Type = "System.Res.Resources"; Component.Assembly = "System.Res"; Component.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Singleton; ComponentConfig.Components.Add(Component.Name, Component); #endregion #region 服務橋 ComponentInfo ServiceBridger = new ComponentInfo(); ServiceBridger.Name = "ServiceBridger"; ServiceBridger.Type = "EAS.Distributed.ServiceBridger"; ServiceBridger.Assembly = "EAS.Distributed.Client"; ServiceBridger.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread; PropertyInfo BridgerProperty = new PropertyInfo(); BridgerProperty.Name = "ServiceName"; BridgerProperty.Type = "string"; BridgerProperty.Expression = "EAS.RMIService.Service"; ServiceBridger.Properties.Add(BridgerProperty.Name, BridgerProperty); ComponentConfig.Components.Add(ServiceBridger.Name, ServiceBridger); #endregion #region 通用資料訪問 ComponentInfo DataAccessor = new ComponentInfo(); DataAccessor.Name = "DataAccessor"; DataAccessor.Type = "EAS.Distributed.DataAccessor"; DataAccessor.Assembly = "EAS.Distributed.Client"; DataAccessor.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread; PropertyInfo DataAccessorProperty = new PropertyInfo(); DataAccessorProperty.Name = "ServiceBridger"; DataAccessorProperty.Type = "object"; DataAccessorProperty.Expression = "ServiceBridger"; DataAccessor.Properties.Add(DataAccessorProperty.Name, DataAccessorProperty); ComponentConfig.Components.Add(DataAccessor.Name, DataAccessor); #endregion #region ORM訪問元件 ComponentInfo OrmAccessor = new ComponentInfo(); OrmAccessor.Name = "OrmAccessor"; OrmAccessor.Type = "EAS.Distributed.OrmAccessor"; OrmAccessor.Assembly = "EAS.Distributed.Client"; OrmAccessor.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread; PropertyInfo OrmBridgerProperty = new PropertyInfo(); OrmBridgerProperty.Name = "ServiceBridger"; OrmBridgerProperty.Type = "object"; OrmBridgerProperty.Expression = "ServiceBridger"; OrmAccessor.Properties.Add(OrmBridgerProperty.Name, OrmBridgerProperty); PropertyInfo OrmDACProperty = new PropertyInfo(); OrmDACProperty.Name = "DataAccessor"; OrmDACProperty.Type = "object"; OrmDACProperty.Expression = "DataAccessor"; OrmAccessor.Properties.Add(OrmDACProperty.Name, OrmDACProperty); ComponentConfig.Components.Add(OrmAccessor.Name, OrmAccessor); #endregion } }
再程式執行前 執行BeforStart.EASConfig();
配置檔案中只需要保留很少一部分資訊
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="eas" type="EAS.ConfigHandler,EAS.MicroKernel" /> </configSections> <!--SQLite執行必需--> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> <eas> <configurations> <item name="WorkstationUser" value="Administrator" /> <item name="LastUser" value="Administrator" /> </configurations> <services> <service name="EAS.RMIService.Service" service-type="WcfService" singleton="true" url="http://localhost:8888/eas/services/EAS.RMIService" /> </services> </eas> </configuration>